You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat >c41.py <<'# EOF'try: print(list([1], [2]))except TypeError as e: print(e)try: print(list([x for x in "XYZ"], []))except TypeError as e: print(e)try: print(list([x for x in "XYZ"], foo=[]))except TypeError as e: print(e)try: print(dict({"A": 1}, {"B": 2}))except TypeError as e: print(e)
# EOF
$ python c41.pylist expected at most 1 argument, got 2list expected at most 1 argument, got 2list() takes no keyword argumentsdict expected at most 1 argument, got 2
$ ruff --isolated check --select C410,C411,C418 c41.py --unsafe-fixes --fixFound 4 errors (4 fixed, 0 remaining).
$ cat c41.pytry: print([1])except TypeError as e: print(e)try: print([x for x in "XYZ"])except TypeError as e: print(e)try: print([x for x in "XYZ"])except TypeError as e: print(e)try: print({"A": 1})except TypeError as e: print(e)
$ python c41.py[1]['X', 'Y', 'Z']['X', 'Y', 'Z']{'A': 1}
The text was updated successfully, but these errors were encountered:
… (kw)args for `C410`,`C411`, and `C418` (#15838)
Both `list` and `dict` expect only a single positional argument. Giving
more positional arguments, or a keyword argument, is a `TypeError` and
neither the lint rule nor its fix make sense in that context.
Closes#15810
Description
unnecessary-literal-within-list-call
(C410),unnecessary-list-call
(C411), andunnecessary-literal-within-dict-call
(C418) have false positives in Ruff 0.9.3 when thelist
ordict
call has too many positional arguments or (for C411) there is a keyword argument. Their fixes suppressTypeError
s.The text was updated successfully, but these errors were encountered: