Do not import duplicated modules with --importmode=importlib#12074
Do not import duplicated modules with --importmode=importlib#12074nicoddemus merged 1 commit intopytest-dev:mainfrom
Conversation
Regression brought up by pytest-dev#11475.
|
@flying-sheep I could not reproduce the issue using your reproducer, in Perhaps this is due to me running Windows? Can you try this branch yourself perhaps? |
bluetech
left a comment
There was a problem hiding this comment.
Regardless of whether it fixes @flying-sheep's issue, the change LGTM
|
Ah, sorry, the reproducer didn’t do what I thought it did. This one works. I’ll check if this PR fixes things: git clone https://github.com/scverse/anndata.git -b src2
cd anndata
python -m venv .venv
.venv/bin/pip install .[test] pytest@https://github.com/pytest-dev/pytest/releases/download/8.1.0/pytest-8.1.0-py3-none-any.whl
.venv/bin/pytest anndata src/anndata/tests/test_awkward.py::test_view src/anndata/tests/test_backed_sparse.py::test_empty_backed_indexingFAILED src/anndata/tests/test_awkward.py::test_view[obsm] - Failed: DID NOT WARN. No warnings of type (<class 'anndata._warnings.ImplicitModificationWarning'>,) were emitted.
FAILED src/anndata/tests/test_awkward.py::test_view[varm] - Failed: DID NOT WARN. No warnings of type (<class 'anndata._warnings.ImplicitModificationWarning'>,) were emitted.
ERROR src/anndata/tests/test_backed_sparse.py::test_empty_backed_indexing[zarr-empty_list] - ImportError: cannot import name 'write_zarr' from 'anndata._io.zarr' (/home/phil/Dev/Python/_reproducers/anndata/.venv/lib/python3.11/site-packages/zarr/__init__.py)
ERROR src/anndata/tests/test_backed_sparse.py::test_empty_backed_indexing[zarr-empty_bool_mask] - ImportError: cannot import name 'write_zarr' from 'anndata._io.zarr' (/home/phil/Dev/Python/_reproducers/anndata/.venv/lib/python3.11/site-packages/zarr/__init__.py) |
|
OK, I tried git clone https://github.com/scverse/anndata.git -b src2
cd anndata
python -m venv .venv
.venv/bin/pip install .[test] 'pytest@git+https://github.com/nicoddemus/pytest.git@11475-duplicated-imports'
.venv/bin/pytest anndata src/anndata/tests/test_awkward.py::test_view src/anndata/tests/test_backed_sparse.py::test_empty_backed_indexingand it worked! /edit: running all tests via 🥳 |
|
Awesome, thanks @flying-sheep! |
|
I think this may have introduced a different regression. Consider the following project structure with two packages under the In |
|
Just a little bit of a follow up, because I realize that my original comment wasn't the most clear. Below are the contents of |
|
@aaraney thanks for the report, but could you open a new issue please (you can refer to this one there)? I will take a look at it ASAP. 👍 |
|
@nicoddemus, for sure! Thanks for taking a look at this! |
…dev#12074) Regression brought up by pytest-dev#11475.
|
This appears to have broken assertion re-writing with editable installs. |
|
This is fixed by #12313 |
| pass | ||
| else: | ||
| # If the given module name is already in sys.modules, do not import it again. | ||
| with contextlib.suppress(KeyError): |
There was a problem hiding this comment.
just taking a look again, i believe this should trigger a import mismatch if the file of the loaded module and the current path are different
Regression brought up by #11475.