mypy 1.7.0 results in new [misc] type errors with pydantic usage
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
I was asked to file a bug with more details; it's possible that the behavior is not as much a bug as increased strictness, but given that it impacts a widely used library, I wanted to share (and ask for recommendations on how proceed since manually ignoring this issue across many projects is going to be tedious).
Minimal program:
Minimal setup:
% python --version
Python 3.12.0
% python3 -m venv .venv
% source .venv/bin/activate
% pip install -U pip mypy pydantic
% pip freeze
annotated-types==0.6.0
mypy==1.7.0
mypy-extensions==1.0.0
pydantic==2.4.2
pydantic_core==2.10.1
typing_extensions==4.8.0
% echo "from pydantic import BaseModel" >> example.py
% echo >> example.py
% echo "class Foo(BaseModel):" >> example.py
% echo " pass" >> example.py
% mypy --disallow-any-explicit --disallow-any-decorated example.py
example.py:3: error: Explicit "Any" is not allowed [misc]
example.py:3: error: Type of decorated function contains type "Any" ("Callable[[DefaultNamedArg(dict[str, Any] | None, '__pydantic_extra__'), DefaultNamedArg(set[str], '__pydantic_fields_set__'), DefaultNamedArg(dict[str, Any] | None, '__pydantic_private__')], None]") [misc]
Found 2 errors in 1 file (checked 1 source file)
These errors are not reproducible with mypy 1.6.1
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 den Bericht aus example.py mit Python 3.12, pydantic 2.4.2 und mypy 1.7.0 unter Verwendung des gezeigten Befehls und vergleiche ihn anschließend mit mypy 1.6.1. Verfolge das geänderte Verhalten der Typprüfung und kläre, ob die [misc]-Fehler eine Regression oder erwartete Striktheit sind; abgeschlossen bedeutet eine dokumentierte Lösung oder einen bestätigten Fix.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100