mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[flake8-comprehensions
] Skip when TypeError
present from too many (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
This commit is contained in:
parent
fe516e24f5
commit
071862af5a
9 changed files with 52 additions and 8 deletions
|
@ -11,3 +11,7 @@ list( # comment
|
|||
list([ # comment
|
||||
1, 2
|
||||
])
|
||||
|
||||
# Skip when too many positional arguments
|
||||
# See https://github.com/astral-sh/ruff/issues/15810
|
||||
list([1],[2])
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
x = [1, 2, 3]
|
||||
list([i for i in x])
|
||||
|
||||
# Skip when too many positional arguments
|
||||
# or keyword argument present.
|
||||
# See https://github.com/astral-sh/ruff/issues/15810
|
||||
list([x for x in "XYZ"],[])
|
||||
list([x for x in "XYZ"],foo=[])
|
||||
|
|
|
@ -8,3 +8,6 @@ dict(
|
|||
dict({}, a=1)
|
||||
dict({x: 1 for x in range(1)}, a=1)
|
||||
|
||||
# Skip when too many positional arguments
|
||||
# See https://github.com/astral-sh/ruff/issues/15810
|
||||
dict({"A": 1}, {"B": 2})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue