Weird formatting of __new__ signature in error messages
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
from typing import Tuple, Dict, Any
class MyMeta(type):
def __new__(cls, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> type:
return type.__new__(name, bases, dict)
This MyMeta.__new__ has exactly same signature with type.__new__ in typeshed:
https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L88
But mypy thinks that it's incorrect and offers me to write two same cls args:
test.py:6: note: Possible overload variants:
test.py:6: note: def __new__(cls, cls: Any, o: object) -> type
test.py:6: note: def __new__(cls, cls: Any, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type
No mypy flags was used, mypy --version is 0.620
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
Reproduziere das Beispiel in test.py mit mypy 0.620 und vergleiche anschließend die gemeldeten new-Overloads mit stdlib/3/builtins.pyi von typeshed ungefähr bei Zeile 88. Verfolge, wie mypy die Signatur für type.new formatiert; abgeschlossen ist die Aufgabe, wenn die Diagnose die irreführenden doppelten cls-Argumente nicht mehr präsentiert und dabei die relevanten Overload-Informationen beibehält.
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
- 45/100