Editable installs are not recognized as having typing when using py.typed (setuptools v64 issue)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
mypy does not recognize that libraries installed as editable using pip are fully typed even though the py.typed file is correctly included.
To Reproduce
Working script which installs a NON-editable version of library:
# create python environment with pip
rm -rf nionui
git clone https://github.com/nion-software/nionui.git
pushd nionui
git checkout 0.6.4
python -m pip install mypy numpy imageio types-pytz types-tzlocal types-setuptools
# the next line is the only change between these two scripts
python -m pip install nionutils==0.4.4
mypy --namespace-packages --ignore-missing-imports --follow-imports=silent --install-types --non-interactive --strict --no-warn-redundant-casts --no-warn-unused-ignores -p nion.ui -p nionui_app.nionui_examples
popd
# success
Failing version which installs an editable version of a library:
# create python environment with pip
rm -rf nionui
git clone https://github.com/nion-software/nionui.git
pushd nionui
git checkout 0.6.4
python -m pip install mypy numpy imageio types-pytz types-tzlocal types-setuptools nionutils
# the next line is the only change between these two scripts
python -m pip install -e git+https://github.com/nion-software/nionutils.git@0.4.4#egg=nionutils
mypy --namespace-packages --ignore-missing-imports --follow-imports=silent --install-types --non-interactive --strict --no-warn-redundant-casts --no-warn-unused-ignores -p nion.ui -p nionui_app.nionui_examples
popd
# failure
Expected Behavior
These should work the same. The source client and underlying library are the same in both cases except one is installed as an editable install.
Actual Behavior
The failing version gives type errors:
nion/ui/DrawingContext.py:790: error: Returning Any from function declared to return "Optional[str]"
nion/ui/DrawingContext.py:794: error: Returning Any from function declared to return "Optional[str]"
nion/ui/DrawingContext.py:798: error: Returning Any from function declared to return "Optional[str]"
nion/ui/CanvasItem.py:2780: error: Class cannot subclass "Observable" (has type "Any")
nion/ui/UserInterface.py:3217: error: Returning Any from function declared to return "int"
nion/ui/UserInterface.py:3224: error: Returning Any from function declared to return "int"
nion/ui/UserInterface.py:3620: error: Class cannot subclass value of type "Any"
nion/ui/UserInterface.py:3634: error: Class cannot subclass value of type "Any"
nion/ui/Widgets.py:382: error: Returning Any from function declared to return "AbstractSet[int]"
nion/ui/Declarative.py:949: error: Class cannot subclass "Observable" (has type "Any")
nion/ui/Declarative.py:1112: error: Class cannot subclass "Observable" (has type "Any")
nion/ui/GridCanvasItem.py:256: error: Returning Any from function declared to return "int"
Found 12 errors in 6 files (checked 51 source files)
Your Environment
- Mypy version used: 0.971
- Mypy command-line flags: see script
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: Python 3.10.5
- Operating system and version: macOS, Ubuntu 20, didn't try Windows yet
Also note: this behavior seems to have changed around 2022-08-10 to 2022-08-11. Something in the Python ecosystem seems to have changed. Nevertheless, this seems to be a bug in mypy since it is all about whether py.typed is found or not.
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 damit, die beiden Installationsskripte mit mypy 0.971, Python 3.10.5 und den angegebenen Kommandozeilen-Flags zu reproduzieren und dabei die editierbaren und nicht editierbaren Installationen zu vergleichen. Verfolge, wie mypy py.typed für das installierte nionutils-Paket findet; abgeschlossen ist die Aufgabe, wenn beide Installationsmodi die Bibliothek als typisiert erkennen und die gemeldeten Fehler verschwinden.
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
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100