Harmonise return type of builtins.__import__ and importlib.import_module - #6302
Merged
Conversation
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: isort (https://github.com/pycqa/isort.git)
+ isort/_future/__init__.py:9: error: unused "type: ignore" comment
+ isort/_future/__init__.py:10: error: unused "type: ignore" comment
+ isort/output.py:504: error: unused "type: ignore" comment
+ isort/output.py:516: error: unused "type: ignore" comment
+ isort/output.py:523: error: unused "type: ignore" comment
pip (https://github.com/pypa/pip.git)
- src/pip/_internal/locations/__init__.py:68: error: Module has no attribute "platlibdir"
+ src/pip/_internal/network/session.py:106: error: unused "type: ignore" comment
kornia (https://github.com/kornia/kornia.git)
- kornia/testing/__init__.py:16: error: Module has no attribute "util" [attr-defined]
ibis (https://github.com/ibis-project/ibis.git)
- ibis/backends/tests/conftest.py:45: error: Module has no attribute "TestConf"
python-chess (https://github.com/niklasf/python-chess.git)
+ chess/engine.py:122: error: unused "type: ignore" comment
+ chess/engine.py:123: error: unused "type: ignore" comment
+ chess/engine.py:1209: error: unused "type: ignore" comment
anyio (https://github.com/agronholm/anyio.git)
+ src/anyio/_core/_eventloop.py:56: error: unused "type: ignore" comment
sphinx (https://github.com/sphinx-doc/sphinx.git)
+ sphinx/util/typing.py:228: error: unused "type: ignore" comment
+ sphinx/util/typing.py:428: error: unused "type: ignore" comment
+ sphinx/util/inspect.py:424: error: unused "type: ignore" comment
+ sphinx/util/inspect.py:427: error: unused "type: ignore" comment
+ sphinx/util/inspect.py:430: error: unused "type: ignore" comment
+ sphinx/util/docutils.py:52: error: unused "type: ignore" comment
+ sphinx/util/docutils.py:53: error: unused "type: ignore" comment
+ sphinx/util/docutils.py:67: error: unused "type: ignore" comment
+ sphinx/util/docutils.py:81: error: unused "type: ignore" comment
+ sphinx/util/docutils.py:95: error: unused "type: ignore" comment
+ sphinx/util/docutils.py:110: error: unused "type: ignore" comment
+ sphinx/domains/python.py:1452: error: unused "type: ignore" comment
+ sphinx/writers/manpage.py:110: error: unused "type: ignore" comment
+ sphinx/testing/util.py:126: error: unused "type: ignore" comment
+ sphinx/testing/util.py:127: error: unused "type: ignore" comment
+ sphinx/util/compat.py:29: error: unused "type: ignore" comment
aiohttp (https://github.com/aio-libs/aiohttp.git)
+ aiohttp/connector.py:1306: error: unused "type: ignore" comment
+ aiohttp/web_runner.py:181: error: unused "type: ignore" comment
+ aiohttp/pytest_plugin.py:244: error: unused "type: ignore" comment
streamlit (https://github.com/streamlit/streamlit.git)
+ lib/streamlit/script_runner.py:432: error: unused "type: ignore" comment
+ lib/streamlit/script_runner.py:439: error: unused "type: ignore" comment
werkzeug (https://github.com/pallets/werkzeug.git)
+ src/werkzeug/_reloader.py:20: error: unused "type: ignore" comment
- tests/test_wrappers.py:833: note: Use "-> None" if function does not return a value
- tests/test_wrappers.py:856: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
+ tests/test_wrappers.py:833: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
core (https://github.com/home-assistant/core.git)
+ homeassistant/components/http/forwarded.py:91: error: unused "type: ignore" comment
+ homeassistant/auth/mfa_modules/__init__.py:136: error: unused "type: ignore" comment
+ homeassistant/auth/mfa_modules/__init__.py:171: error: unused "type: ignore" comment
+ homeassistant/auth/providers/__init__.py:145: error: unused "type: ignore" comment
+ homeassistant/auth/providers/__init__.py:178: error: unused "type: ignore" comment
+ homeassistant/config.py:648: error: unused "type: ignore" comment
+ homeassistant/config.py:651: error: unused "type: ignore" comment
+ homeassistant/config.py:662: error: unused "type: ignore" comment
+ homeassistant/config.py:672: error: unused "type: ignore" comment
+ homeassistant/config.py:673: error: unused "type: ignore" comment
+ homeassistant/config.py:753: error: unused "type: ignore" comment
+ homeassistant/config.py:895: error: unused "type: ignore" comment
+ homeassistant/setup.py:241: error: unused "type: ignore" comment
+ homeassistant/setup.py:246: error: unused "type: ignore" comment
+ homeassistant/helpers/check_config.py:161: error: unused "type: ignore" comment
+ homeassistant/config_entries.py:304: error: unused "type: ignore" comment
+ homeassistant/config_entries.py:443: error: unused "type: ignore" comment
+ homeassistant/config_entries.py:482: error: unused "type: ignore" comment
+ homeassistant/config_entries.py:519: error: unused "type: ignore" comment
+ homeassistant/helpers/condition.py:929: error: unused "type: ignore" comment
+ homeassistant/helpers/condition.py:977: error: unused "type: ignore" comment
+ homeassistant/helpers/script.py:260: error: unused "type: ignore" comment
+ homeassistant/helpers/script.py:262: error: unused "type: ignore" comment
+ homeassistant/helpers/script.py:269: error: unused "type: ignore" comment
+ homeassistant/scripts/__init__.py:67: error: unused "type: ignore" comment
+ homeassistant/helpers/reload.py:81: error: unused "type: ignore" comment
+ homeassistant/helpers/reload.py:82: error: unused "type: ignore" comment
+ homeassistant/components/notify/legacy.py:61: error: unused "type: ignore" comment
+ homeassistant/components/notify/legacy.py:66: error: unused "type: ignore" comment
+ homeassistant/components/device_tracker/legacy.py:241: error: unused "type: ignore" comment
+ homeassistant/components/device_tracker/legacy.py:246: error: unused "type: ignore" comment
+ homeassistant/components/device_tracker/legacy.py:251: error: unused "type: ignore" comment
+ homeassistant/components/device_tracker/legacy.py:256: error: unused "type: ignore" comment
edgedb (https://github.com/edgedb/edgedb.git)
+ edb/server/pgconnparams.py:75: error: unused "type: ignore" comment
|
Member
Author
This seems like it just makes a lot of people's lives easier, if they were just switching off the type-checker whenever they were doing a dynamic import. |
srittau
approved these changes
Nov 15, 2021
srittau
left a comment
Collaborator
There was a problem hiding this comment.
Looks quite promising. Waiting for @JelleZijlstra's input.
JelleZijlstra
approved these changes
Nov 15, 2021
Member
Author
|
Thanks, both! 😀 |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is an attempt at solving #6295 by adding
__getattr__totypes.ModuleTypeand changing the return type ofbuiltins.__import__so that it now returnstypes.ModuleTyperather thanAny.