-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support namespace packages without namespace-packages
setting
#6114
Comments
@hauntsaninja - no pressure to respond, but I'm curious if you'd have any advice here based on your experiences in Mypy. This issue is roughly referring to the behavior Mypy has in the |
It's also plausible that our current approach of requiring namespace packages to be explicitly enumerated is not that bad and fine to preserve for now. |
mypy's default behaviour isn't very good for actual namespace packages... It's good for "accidental" namespace packages, where you have a large tree and people forget to litter I'd probably recommend using something like mypy's behaviour with Seems potentially a little annoying to list all namespace packages out, seems preferable to list bases. |
Thank you, that's helpful. |
An argument against using literally mypy's Honestly, maybe mypy should probably just use sys.path of the target interpreter to determine bases. This is very defensible behaviour and unlike ruff mypy does usually have a target interpreter that has the installs needed. |
👍 Yeah monorepo support is important for Ruff. We do currently treat each |
pyright while not python does still call python for sys.path. Beyond helping with namespace packages it also deals helps a lot of import weirdness like handling .pth files/ways sys.path can be modified. Pylint's namespace package detection is buggy and I haven't seen an approach that really works besides explicitness/sys.path. Here's a test repo that's small but is already enough to lead to issues for number of tools due to there being files with same name that are distinguished if you detect namespace packages correctly. |
Right now, our module discovery doesn't support namespace packages -- or rather, it requires that projects specify namespace packages explicitly via the
namespace-packages
setting.I'd like to remove this setting, and ensure that namespace packages "just work".
One option is to take inspiration from Mypy, where they effectively mark a directory without a
__init__.py[i]
file as a namespace package if it's within a directory that contains an__init__.py[i]
file, and provide escape hatches for explicitly specifying package bases.Another option is to take inspiration Pyright, where AFAICT they allow you to specify multiple roots which are effectively your package bases.
The text was updated successfully, but these errors were encountered: