albertas / deadcode

Find and fix unused Python code using command line.
GNU Affero General Public License v3.0
56 stars 1 forks source link

Always True ifs are removed #3

Closed b-v closed 8 months ago

b-v commented 9 months ago

Nice package. I did run into the following problem. When I try to run deadcode --fix on the following

a=0
if True:
    a=1
    print(a)

print(a)

then it changes it to

a=0
print(a)

The expected behaviour would be

a=0
a=1
print(a)
print(a)

or just leaving the if intact.

albertas commented 8 months ago

Thank you for reporting this bug.

I have disabled unreachable code detection and fixing in deadcode==2.2.1. I will put this feature request into my backlog.