-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
ModuleNotFoundError during plugin execution on submodule of namespace package. #8332
Comments
It's not something I can dig into near term, sorry |
hmm, if it works correctly for normal pytest items but not for custom plugin items, then there's probably some missing gap that makes the two different that we should enhance for plugin authors (as much as I personally think pytest-flake8 / pytest-black / pytest-mypy / etc. are bad ideas and this is just an expected side-effect of putting a square peg into a round hole) |
The issue appears to be in Lines 570 to 584 in 12e7db8
When called for a file in the subpackage, it infers the incorrect directory:
In the case of the affected projects, I'd expect that function to return Indeed, that's the same conclusion in the last comment of #5147. |
…version 3.5.0 Jason R. Coombs (7): Require Python 3.7 or later. Remove filtered warnings, addressed upstream. method_cache just accepts the lru_cache as the default value. Add type annotations for method_cache. Disable mypy tests. Workaround for pytest-dev/pytest#8332. Update changelog. Update changelog.
After solving the namespace package issues in import-mode=importlib, I'm able to re-enable the plugins without an issue, so I consider this issue resolved. |
…0 to version 3.8.1 Jason R. Coombs (10): Leverage pytest-enabler 2.2 for the default config. Prefer 3.x for Python version (latest stable). Collapse skeleton history. Workaround for jaraco/skeleton#87. Add links to project home page and pypi. Fixes jaraco/skeleton#77. Replace redundant step names with simple 'Run'. Increase visibility of security policy. (#4) Remove TOX_WORK_DIR workaround, no longer necessary with tox 4. Ref tox-dev/tox#3050. Restore type ignorance repairing linter mangling. Restore mypy; import-mode importlib is working. Ref pytest-dev/pytest#8332 Finalize
In jaraco/jaraco.site#1, I stumbled onto another obscure error implicating namespace packages.
In this branch, I pared the issue down to a minimal repro.
As you can see, even though
jaraco
is a namespace package (works forimport jaraco.site.projecthoneypot.croakysteel
), when pytest attempts to importcroakysteel
, it incorrectly detects thatjaraco
is part of the package ancestry, so incorrectly importssite
as a top-level package and notjaraco.site
.This issue goes away if
pytest-black
isn't used, but is also triggered by other plugins likepytest-mypy
orpytest-flake8
.This issue is similar to #3396, but doesn't involve doctests. It's similar to #5147, but only affects plugins.
The text was updated successfully, but these errors were encountered: