gentle-painting-24549
12/22/2022, 9:57 PM<pants_respective_source>/tests/conftest.py
prevents MyPy checks from running - Iβm wondering if this is a pants bug / mypy issue / user error. More details and git example in π§΅
packages/package-2/tests/conftest.py: error: Duplicate module named "conftest" (also at "packages/package-1/tests/conftest.py")
βββ .gitignore
βββ 3rdparty
β βββ BUILD
β βββ python
β β βββ default.lock
β βββ requirements.txt
βββ README.md
βββ packages
β βββ package-1
β β βββ BUILD
β β βββ package_1
β β β βββ __init__.py
β β β βββ foo.py
β β βββ tests
β β βββ conftest.py
β β βββ test_foo.py
β βββ package-2
β βββ BUILD
β βββ package_2
β β βββ __init__.py
β β βββ baz.py
β βββ tests
β βββ conftest.py
β βββ test_baz.py
βββ pants
βββ pants.toml
Example Build File:
python_sources(
name="lib",
sources=[
"package_1/**/*.py",
"package_1/*.py",
],
)
python_test_utils(name="conftest", sources=["tests/conftest.py"])
python_tests(
name="tests",
sources=[
"tests/**/test_*.py",
"tests/test_*.py",
],
dependencies=[
":lib",
":conftest",
],
)
β― ./pants check ::
14:58:16.01 [ERROR] Completed: Typecheck using MyPy - mypy failed (exit code 2).
packages/package-2/tests/conftest.py: error: Duplicate module named "conftest" (also at "packages/package-1/tests/conftest.py")
packages/package-2/tests/conftest.py: note: See <https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules> for more info
packages/package-2/tests/conftest.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
Found 1 error in 1 file (errors prevented further checking)
broad-processor-92400
12/22/2022, 10:25 PMtests
directory, e.g. package-1/tests/_*test_package_1*_/conftest.py
(plus an adjacent __init__.py
), so that mypy sees test_package_1.conftest
and test_package_2.conftest
rather than just conftest
. This is a bit clunky though, and we may change it.
I believe the pants project itself puts tests in with source, e.g. within package-1/package_1/
there's foo.py
, foo_test.py
, conftest.py
happy-kitchen-89482
12/22/2022, 10:53 PM./pants roots
for a list of them as currently configured)gentle-painting-24549
12/22/2022, 10:57 PMpackages/package-1
packages/package-2
so AFAICT thereβs two duplicate modules: tests.conftest
regardless of whether I place an __init__.py
or pass a combination of --explicit-package-bases
/ --package-namespace
happy-kitchen-89482
12/22/2022, 11:01 PMtests1.conftest
?gentle-painting-24549
12/22/2022, 11:08 PMpackages/package-1/tests/test_generic_name.py
and packages/package-2/tests/test_generic_name.py
happy-kitchen-89482
12/22/2022, 11:12 PM