| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Diff from mypy_primer, showing the effect of this PR on open source code: pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/assertion/rewrite.py:130: error: Argument "submodule_search_locations" to "spec_from_file_location" has incompatible type "MutableSequence[str] | None"; expected "list[str] | None" [arg-type]
|
Sorry, something went wrong.
|
This change causes an issue with importlib._bootstrap_external.spec_from_file_location - specifically on this line: https://github.com/python/cpython/blob/main/Lib/importlib/_bootstrap_external.py#L892 if spec.submodule_search_locations == []:Empty _NamespacePath containers don't override __eq__ (so they fall back to object.__eq__ -> is), so this line will always compare False when passed a namespace package's submodule_search_locations. _NamespacePath also doesn't seem to fulfil the MutableSequence interface - it doesn't have e.g. an insert method. This PR isn't the way to go - I think we need a proper _NamespacePath type. |
Sorry, something went wrong.
|
python/cpython#119668 looks to expose _NamespacePath as public API. Since importlib._bootstrap_external isn't a public module, we can wait to see where _NamespacePath ends up being exposed (importlib or importlib.machinery) and reflect that in the stubs. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Despite the CPython documentation for importlib.machinery.ModuleSpec.submodule_search_locations, this attribute may not be a list - and for CPython at least it is a importlib._bootstrap_external._NamespacePath object for namespace packages. MRE:
The type of .submodule_search_locations mirrors that of types.ModuleType.__path__.
typeshed/stdlib/types.pyi
Line 325 in 1af9de6
(See also #6200)