Skip to content

Delete object.__module__ #8789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Delete object.__module__ #8789

wants to merge 1 commit into from

Conversation

AlexWaygood
Copy link
Member

An alternative approach to #8787

An alternative approach to #8787
@AlexWaygood
Copy link
Member Author

Hmm, 1868 stubtest errors

@github-actions
Copy link
Contributor

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

yarl (https://github.com/aio-libs/yarl)
+ yarl/_url.py:19: error: "object" has no attribute "__module__"  [attr-defined]

SinbadCogs (https://github.com/mikeshardmind/SinbadCogs)
+ devtools/core.py:193: error: "partial[Coroutine[Any, Any, Any]]" has no attribute "__module__"

streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/runtime/legacy_caching/hashing.py: note: In member "_to_bytes" of class "_CodeHasher":
+ lib/streamlit/runtime/legacy_caching/hashing.py:625:16: error: Item "MethodType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:625:16: error: Item "BuiltinFunctionType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:625:16: error: Item "WrapperDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:625:16: error: Item "MethodDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:625:16: error: Item "ClassMethodDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:628:49: error: Item "MethodType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:628:49: error: Item "BuiltinFunctionType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:628:49: error: Item "WrapperDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:628:49: error: Item "MethodDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:628:49: error: Item "ClassMethodDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:642:32: error: Item "MethodType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:642:32: error: Item "BuiltinFunctionType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:642:32: error: Item "WrapperDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:642:32: error: Item "MethodDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]
+ lib/streamlit/runtime/legacy_caching/hashing.py:642:32: error: Item "ClassMethodDescriptorType" of "Union[FunctionType, FunctionType, MethodType, BuiltinFunctionType, BuiltinFunctionType, WrapperDescriptorType, MethodDescriptorType, ClassMethodDescriptorType]" has no attribute "__module__"  [union-attr]

bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/core/property/enum.py: note: In function "_sphinx_type":
+ src/bokeh/core/property/enum.py:105:28: error: "Enumeration" has no attribute "__module__"  [attr-defined]

core (https://github.com/home-assistant/core)
+ homeassistant/helpers/deprecation.py:39: error: "_ObjectT" has no attribute "__module__"  [attr-defined]
+ homeassistant/components/smartthings/__init__.py:290: error: "DeviceBroker" has no attribute "__module__"  [attr-defined]

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/http/request/__init__.py:191: error: "Request" has no attribute "__module__"

rich (https://github.com/Textualize/rich)
+ rich/console.py:946: error: "TextIO" has no attribute "__module__"  [attr-defined]

discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/bot.py:888: error: "Cog" has no attribute "__module__"

mypy (https://github.com/python/mypy)
+ mypy/test/teststubgen.py:1046: error: "StubgencSuite" has no attribute "__module__"  [attr-defined]
+ mypy/test/teststubgen.py:1093: error: "StubgencSuite" has no attribute "__module__"  [attr-defined]

alerta (https://github.com/alerta/alerta)
+ alerta/webhooks/__init__.py:33: error: "WebhookBase" has no attribute "__module__"

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/typing.py: note: In function "stringify":
+ sphinx/util/typing.py:359:13: error: "TypeVar" has no attribute "__module__"  [attr-defined]
+ sphinx/util/typing.py:363:42: error: "TypeVar" has no attribute "__module__"  [attr-defined]
+ sphinx/util/nodes.py: note: In function "get_full_module_name":
+ sphinx/util/nodes.py:91:27: error: "Node" has no attribute "__module__"  [attr-defined]

pytest (https://github.com/pytest-dev/pytest)
+ testing/test_warning_types.py:20: error: "UserWarning" has no attribute "__module__"  [attr-defined]
+ testing/test_config.py:1294: error: "My" has no attribute "__module__"  [attr-defined]

antidote (https://github.com/Finistere/antidote)
+ src/antidote/_internal/utils.py:77: error: Item "MethodType" of "Union[type, FunctionType, MethodType]" has no attribute "__module__"
+ src/antidote/_internal/utils.py:78: error: Item "MethodType" of "Union[type, FunctionType, MethodType]" has no attribute "__module__"

@AlexWaygood
Copy link
Member Author

Seems like mypy struggles to infer that the __module__ attribute is inherited from type for class objects

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.

1 participant