-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIM401 should not apply to non-concrete default values #1809
Labels
bug
Something isn't working
Comments
Ahh, good catch! We can fix this. |
Thanks! |
I went off some heuristics (ignore any expressions containing function calls, awaits, etc.) — let me know if it misses anything going forward. |
They look like sufficient for my code base! Thanks so much :D |
We should also ignore subscripting, since it might throw - if "title" in fileinfo:
- file_name = fileinfo["title"]
- else:
- file_name = fileinfo["name"]
+ file_name = fileinfo.get("title", fileinfo["name"]) |
Makes sense, I can fix that. |
charliermarsh
added a commit
that referenced
this issue
Jan 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks again for Ruff ❤️
As of
ruff==0.0.219
SIM401
seems to be incorrectly applied when the default value is not a constant value.Believes it can be simplified (& maybe more dangerously will be auto-fixed) to:
However these two are not interchangeable as
some_async_func()
may be arbitrarily expensive as demonstrated here by theasyncio.sleep(10)
Note: This is also a bug in upstream flake8-simplify MartinThoma/flake8-simplify#166
The text was updated successfully, but these errors were encountered: