[flake8-simplify] More precise inference for dictionaries (SIM300) (#15164)

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
InSync 2024-12-30 17:41:33 +07:00 committed by GitHub
parent 0caab81d3d
commit 0b15f17939
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 67 additions and 42 deletions

View file

@ -14,6 +14,7 @@ JediOrder.YODA == age # SIM300
0 < (number - 100) # SIM300
B<A[0][0]or B
B or(B)<A[0][0]
{"non-empty-dict": "is-ok"} == DummyHandler.CONFIG
# Errors in preview
['upper'] == UPPER_LIST
@ -39,4 +40,7 @@ age == JediOrder.YODA
(number - 100) > 0
SECONDS_IN_DAY == 60 * 60 * 24 # Error in 0.1.8
SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # Error in 0.1.8
{"non-empty-dict": "is-ok"} == DummyHandler.CONFIG
# https://github.com/astral-sh/ruff/issues/14761
{"": print(1)} == print(2)
{0: 1, **print(2)} == print(4)