-
Notifications
You must be signed in to change notification settings - Fork 275
namedtuple with cls in field names gives type warnings #3184
Copy link
Copy link
Closed
astral-sh/ruff
#24333Labels
Description
Summary
The following will give multiple type warnings. Also seeing it on pyrefly but not with mypy or pyright.
from collections import namedtuple
PInfo = namedtuple("PInfo", "inst cls")
PInfo(None, str) # works
PInfo(inst=None, cls=str) # problemNo argument provided for required parameter `cls` (missing-argument) [Ln 5, Col 1]
Multiple values provided for parameter `cls` (parameter-already-assigned) [Ln 5, Col 18]
Argument is incorrect: Argument type `str` does not satisfy upper bound `PInfo` of type variable `Self` (invalid-argument-type) [Ln 5, Col 18]
Argument is incorrect: Expected `type[PInfo]`, found `<class 'str'>` (invalid-argument-type) [Ln 5, Col 18]
https://play.ty.dev/93b9b1e5-98bc-4a5d-aa74-04a72a52780e
Version
ty 0.0.26
Reactions are currently unavailable