Repository navigation
Avoid unnecessary setattr lookups, ignore object.__setattr__ - #22270
Open
hauntsaninja wants to merge 1 commit into
Open
hauntsaninja wants to merge 1 commit into
hauntsaninja wants to merge 1 commit into
Conversation
This makes mypy 10% faster on the colour-science/colour codebase
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/compression_utils.py:156:54: error: Argument 1 to "ZLibBackendWrapper" has incompatible type Module; expected "ZLibBackendProtocol" [arg-type]
+ aiohttp/compression_utils.py:156:54: note: Protocol member ZLibBackendProtocol.MAX_WBITS expected settable variable, got read-only attribute
+ aiohttp/compression_utils.py:156:54: note: Protocol member ZLibBackendProtocol.Z_BEST_SPEED expected settable variable, got read-only attribute
+ aiohttp/compression_utils.py:156:54: note: <3 more conflict(s) not shown>
core (https://github.com/home-assistant/core)
+ homeassistant/helpers/trigger/__init__.py:503: error: Argument 3 to "_register_trigger_platform" has incompatible type Module; expected "TriggerProtocol" [arg-type]
+ homeassistant/helpers/trigger/__init__.py:503: note: Protocol member TriggerProtocol.TRIGGER_SCHEMA expected settable variable, got read-only attribute
+ homeassistant/helpers/trigger/__init__.py:505: error: Incompatible return value type (got "tuple[str, Module]", expected "tuple[str, TriggerProtocol]") [return-value]
+ homeassistant/loader.py:1137: error: Incompatible return value type (got Module | ComponentProtocol, expected "ComponentProtocol") [return-value]
+ homeassistant/loader.py:1215: error: Incompatible return value type (got Module | ComponentProtocol, expected "ComponentProtocol") [return-value]
+ homeassistant/loader.py:1242: error: Incompatible return value type (got Module | ComponentProtocol, expected "ComponentProtocol") [return-value]
schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/specs/openapi/error_feedback.py: note: In member "apply" of class "NumericBoundAdjustment":
+ src/schemathesis/specs/openapi/error_feedback.py:415: error: Non-overlapping container check (element type: "SpecificationAdapter", container item type: Module) [comparison-overlap]
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/_cli/__init__.py: note: In function "_load_subcommand_descriptions":
+ sphinx/_cli/__init__.py:58:37: error: Incompatible types in assignment (expression has type Module, variable has type "_SubcommandModule") [assignment]
+ sphinx/_cli/__init__.py:58:37: note: Protocol member _SubcommandModule.parser_description expected settable variable, got read-only attribute
+ sphinx/_cli/__init__.py:58:37: note: Protocol member _SubcommandModule.run expected settable variable, got read-only attribute
+ sphinx/_cli/__init__.py:58:37: note: <1 more conflict(s) not shown>
+ sphinx/_cli/__init__.py: note: In function "_load_subcommand":
+ sphinx/_cli/__init__.py:272:37: error: Incompatible types in assignment (expression has type Module, variable has type "_SubcommandModule") [assignment]
+ sphinx/_cli/__init__.py:272:37: note: Protocol member _SubcommandModule.parser_description expected settable variable, got read-only attribute
+ sphinx/_cli/__init__.py:272:37: note: Protocol member _SubcommandModule.run expected settable variable, got read-only attribute
+ sphinx/_cli/__init__.py:272:37: note: <1 more conflict(s) not shown>
+ sphinx/util/docutils.py: note: In member "directive" of class "CustomReSTDispatcher":
+ sphinx/util/docutils.py:296:52: error: Argument 2 to "__call__" of "_DirectivesDispatcher" has incompatible type Module; expected "_LanguageModule" [arg-type]
+ sphinx/util/docutils.py:296:52: note: Protocol member _LanguageModule.author_separators expected settable variable, got read-only attribute
+ sphinx/util/docutils.py:296:52: note: Protocol member _LanguageModule.bibliographic_fields expected settable variable, got read-only attribute
+ sphinx/util/docutils.py:296:52: note: <1 more conflict(s) not shown>
scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
|
Collaborator
Author
|
Hmm that's a little annoying. I guess I could just land the optimisation and punt on the "correctness" issue |
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 makes mypy 13% faster on the colour-science/colour codebase. Codex claims it's worth 0.8% on self check too.
Co-authored by Codex