MartinThoma / flake8-simplify

❄ A flake8 plugin that helps you to simplify code
MIT License
185 stars 19 forks source link

[Adjust Rule] SIM908 doesn't work for python 3.7 #159

Open kasium opened 1 year ago

kasium commented 1 year ago

Desired change

Explanation

For python3.7 the rule doesn't work when f-strings are somehow used in functions. However, in pyrhon3.11 it works as expected

Example

import os

def get_framework_info():
    if f"foo" in os.environ:
        port = os.environ[f"foo"]

python3.7: nothing python3.11: Use 'os.environ.get(f"""foo""")' instead of 'if f"""foo""" in os.environ: os.environ[f"""foo"""]'