Hi! I'm not sure if it's something I do wrong or i...
# general
c
Hi! I'm not sure if it's something I do wrong or if there is an issue: I started using a Python monorepo, and some of the test modules in different applications have the same name. Running mypy via "./pants check ::" gives an error because of that. Is there a way to get around that? I tried running separately on each source root, but that's one level too high, would need to list all directories under each root also.
b
Mypy thinks your code is using implicit namespace packages. Slap some
__init__.py
files in the complaining directories and you'll be good to go
c
Unfortunately, that creates other conflicts elsewhere. I think I will have to restructure the projects. It will take a while until the whole monorepo change settles. Thanks!
w
Whats the error? And what's your mypy config?
c
No, if I make the tests directory a package, the conflicts are outside of mypy. There are duplicate package names, and I will probably have to change those. It's a good thing the project is just starting and there's not a lot of changes.
h
Is it just the module name that collides (e g. foo_test.py) or the full path from the source root (e g. path/to/foo_test.py)?
Generally, colliding module basenames are fine but colliding full dotted names can cause trouble, regardless of Pants
b
Yeah IIUC it's an issue with mypy assuming all the files it's been given represent one big project 🫤 There might be mypy settings around it
c
It's weird that it is recommended to not have the tests folder as a package (no init.py) but then one can't easily have utility modules alongside the test_* ones. If thre is no package, the modules are assumed to be top-level and then if two apps have for example test_main.py, then there is a conflict.
b
Python packaging has many quirks 😛
We just do the "tests next to code" thing