-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Change importlib to first try to import modules using the standard mechanism #11997
Commits on Mar 2, 2024
-
testing/test_pathlib: remove
test_issue131_on__init__
The test seems wrong, and we haven't been able to figure out what it's trying to test (the original issue is lost in time).
Configuration menu - View commit details
-
Copy full SHA for 887e251 - Browse repository at this point
Copy the full SHA 887e251View commit details -
Configuration menu - View commit details
-
Copy full SHA for 300ceb4 - Browse repository at this point
Copy the full SHA 300ceb4View commit details -
testing/test_pathlib: add an importlib test
Ensure the implementation isn't changed to trigger such a bug.
Configuration menu - View commit details
-
Copy full SHA for dcf01fd - Browse repository at this point
Copy the full SHA dcf01fdView commit details -
pathlib: extract a function
resolve_pkg_root_and_module_name
Will be reused.
Configuration menu - View commit details
-
Copy full SHA for 7524e60 - Browse repository at this point
Copy the full SHA 7524e60View commit details -
pathlib: extract a function
_import_module_using_spec
Will be reused.
Configuration menu - View commit details
-
Copy full SHA for 4dea183 - Browse repository at this point
Copy the full SHA 4dea183View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5867426 - Browse repository at this point
Copy the full SHA 5867426View commit details -
pathlib: consider namespace packages in `resolve_pkg_root_and_module_…
…name` This applies to `append` and `prepend` import modes; support for `importlib` mode will be added in a separate change.
Configuration menu - View commit details
-
Copy full SHA for 067daf9 - Browse repository at this point
Copy the full SHA 067daf9View commit details -
Change importlib to first try to import modules using the standard me…
…chanism As detailed in pytest-dev#11475 (comment), currently with `--import-mode=importlib` pytest will try to import every file by using a unique module name, regardless if that module could be imported using the normal import mechanism without touching `sys.path`. This has the consequence that non-test modules available in `sys.path` (via other mechanism, such as being installed into a virtualenv, PYTHONPATH, etc) would end up being imported as standalone modules, instead of imported with their expected module names. To illustrate: ``` .env/ lib/ site-packages/ anndata/ core.py ``` Given `anndata` is installed into the virtual environment, `python -c "import anndata.core"` works, but pytest with `importlib` mode would import that module as a standalone module named `".env.lib.site-packages.anndata.core"`, because importlib module was designed to import test files which are not reachable from `sys.path`, but now it is clear that normal modules should be imported using the standard mechanisms if possible. Now `imporlib` mode will first try to import the module normally, without changing `sys.path`, and if that fails it falls back to importing the module as a standalone module. This also makes `importlib` respect namespace packages. This supersedes pytest-dev#11931. Fix pytest-dev#11475 Close pytest-dev#11931
Configuration menu - View commit details
-
Copy full SHA for c85fce3 - Browse repository at this point
Copy the full SHA c85fce3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5746b8e - Browse repository at this point
Copy the full SHA 5746b8eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 199d4e2 - Browse repository at this point
Copy the full SHA 199d4e2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 111c0d9 - Browse repository at this point
Copy the full SHA 111c0d9View commit details -
testing/test_pathlib: parametrize namespace package option
Test with namespace packages support even when it will not find namespace packages to ensure it will at least not give weird results or crashes.
Configuration menu - View commit details
-
Copy full SHA for aac720a - Browse repository at this point
Copy the full SHA aac720aView commit details -
Configuration menu - View commit details
-
Copy full SHA for d6134bc - Browse repository at this point
Copy the full SHA d6134bcView commit details