Allow keyword arguments when creating namedtuple
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
The program:
from collections import namedtuple
Point = namedtuple(typename='Point', field_names=['x', 'y'])
p_1 = Point(2, 7)
The first line is marked by mypy:
Unexpected arguments to "namedtuple()" [misc]
I think it should be allowed to use argument names in the call.
The second line is marked so:
Too many arguments for "Point" [call-arg]
I think this is definitely a false positive.
(A clear and concise description of what the bug is.)
To Reproduce
# Ideally, a small sample program that demonstrates the problem.
# Or even better, a reproducible playground link https://mypy-play.net/ (use the "Gist" button)
Expected Behavior
Actual Behavior
Your Environment
- Mypy version used: 1.7.1
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.11.4
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem collections.namedtuple-Reproducer und führe darauf mypy aus, um zu bestätigen, dass beide Diagnosen auftreten. Verfolge nach, wie namedtuple-Aufrufe und der generierte Point-Konstruktor analysiert werden; erledigt ist die Aufgabe, wenn Schlüsselwortargumente akzeptiert werden und der falsch-positive Fehler bei Point(2, 7) verschwunden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 43/100