Incorrect mapping of actual to formal arguments.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
def takes_at_least3(a1: str, a2: str, a3: str, *args: str) -> None: ...
def test(
x0: tuple[str, ...],
x1: tuple[str, *tuple[str, ...]],
x2: tuple[str, str, *tuple[str, ...]],
x3: tuple[str, str, str, *tuple[str, ...]],
) -> None:
takes_at_least3(*x0) # no error
takes_at_least3(*x1) # Missing positional arguments "x2", "x3"
takes_at_least3(*x2) # no error
takes_at_least3(*x3) # no error
https://mypy-play.net/?mypy=latest&python=3.12&gist=34662974552c517610691a6b5a792ba2
There are only 2 logically sensible results here:
- All of x0-x3 should be accepted
- Only x3 should be accepted, since it is the only type that is guaranteed to provide at least 3 items
The choice depends on whether we consider tuple[str, ...] as equal to
- The union type
tuple[()] | tuple[str] | tuple[str, str] | ... - The gradual
AnyOf[tuple[()], tuple[str], tuple[str, str], ... ](https://github.com/python/typing/issues/566)
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 der verknüpften mypy-play-Reproduktion und konzentriere dich darauf, wie die Aufrufe von takes_at_least3 gegen x0 bis x3 geprüft werden. Prüfe die beiden im Issue vorgeschlagenen Interpretationen von tuple[str, ...] und ermittle, welches Argument-Mapping-Verhalten spezifiziert werden sollte. Als erledigt gilt die Aufgabe, wenn das gewählte Verhalten konsistent implementiert und durch einen Regressionstestfall für das Beispiel abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100