Skip to content

Mention implicit export on missing attribute access - #13917

Merged
hauntsaninja merged 2 commits into
python:masterfrom
hauntsaninja:noreexp
Oct 19, 2022
Merged

hauntsaninja merged 2 commits into
python:masterfrom
hauntsaninja:noreexp

Conversation

@hauntsaninja

Copy link
Copy Markdown
Collaborator

Also only suggest public API for attribute access suggestions

Fixes #13908

Accomplishes a similar thing to #9084 (the logic from there could be improved too, will send a PR for that next)

Also only suggest public API for attribute access suggestions

Fixes python#13908

Accomplishes a similar thing to python#9084 (the logic from there could be
improved too, will send a PR for that next)
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

urllib3 (https://github.com/urllib3/urllib3)
- docs/conf.py:55: error: Module has no attribute "__version__"  [attr-defined]
+ docs/conf.py:55: error: "Module urllib3" does not explicitly export attribute "__version__"  [attr-defined]

streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/watcher/local_sources_watcher_test.py:232:13: error: Module has no attribute "get_default_path_watcher_class"  [attr-defined]
+ lib/tests/streamlit/watcher/local_sources_watcher_test.py:232:13: error: "Module streamlit.watcher.local_sources_watcher" does not explicitly export attribute "get_default_path_watcher_class"  [attr-defined]
- lib/tests/streamlit/watcher/local_sources_watcher_test.py:238:13: error: Module has no attribute "get_default_path_watcher_class"  [attr-defined]
+ lib/tests/streamlit/watcher/local_sources_watcher_test.py:238:13: error: "Module streamlit.watcher.local_sources_watcher" does not explicitly export attribute "get_default_path_watcher_class"  [attr-defined]
- lib/tests/streamlit/watcher/local_sources_watcher_test.py:244:13: error: Module has no attribute "get_default_path_watcher_class"  [attr-defined]
+ lib/tests/streamlit/watcher/local_sources_watcher_test.py:244:13: error: "Module streamlit.watcher.local_sources_watcher" does not explicitly export attribute "get_default_path_watcher_class"  [attr-defined]
- lib/tests/streamlit/watcher/local_sources_watcher_test.py:249:30: error: Module has no attribute "get_default_path_watcher_class"  [attr-defined]
+ lib/tests/streamlit/watcher/local_sources_watcher_test.py:249:30: error: "Module streamlit.watcher.local_sources_watcher" does not explicitly export attribute "get_default_path_watcher_class"  [attr-defined]
- lib/tests/streamlit/watcher/local_sources_watcher_test.py:253:17: error: Module has no attribute "get_default_path_watcher_class"  [attr-defined]
+ lib/tests/streamlit/watcher/local_sources_watcher_test.py:253:17: error: "Module streamlit.watcher.local_sources_watcher" does not explicitly export attribute "get_default_path_watcher_class"  [attr-defined]
- lib/tests/streamlit/web/server/server_test.py:291:42: error: Module has no attribute "ConfigOption"  [attr-defined]
+ lib/tests/streamlit/web/server/server_test.py:291:42: error: "Module streamlit.config" does not explicitly export attribute "ConfigOption"  [attr-defined]

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message was very confusing! 👍

@hauntsaninja
hauntsaninja merged commit 9bba377 into python:master Oct 19, 2022
@hauntsaninja
hauntsaninja deleted the noreexp branch October 19, 2022 21:43
hauntsaninja added a commit to hauntsaninja/mypy that referenced this pull request Oct 19, 2022
Related to python#13917 and python#13908. This handles situations involving
per-module re-exports correctly / is consistent with the error you'd get
with attribute access.
hauntsaninja added a commit that referenced this pull request Oct 20, 2022
Related to #13917 and #13908. This handles situations involving
per-module re-exports correctly / is consistent with the error you'd get
with attribute access.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing from non-py.typed module -> "Module has no attribute" with --strict; mypy still suggests the names it doesn't accept

2 participants