Remove Unnecessary Cast
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery refactoring id: remove-unnecessary-cast
Section titled “Sourcery refactoring id: remove-unnecessary-cast”Description
Section titled “Description”Remove unnecessary casts to int, str, float and bool
Before
Section titled “Before”num_hats = 1update_hat_count(int(num_hats))num_hats = 1update_hat_count(num_hats)Explanation
Section titled “Explanation”If a variable is already an int, str, float or bool it is unnecessary to
wrap it in the associated call later on in the code. Removing these unnecessary
casts is a small improvement in readability, and can eliminate the mental
overhead of trying to figure out why or whether the cast is required.