doesn't detect imports from implicit namespace packages (PEP 420)
Description
Currently, I have these files:
your-repo/
├── ml/
│ └── ... ml code
├── scripts/
│ └── ... scripts code
├── pyproject.toml
With pyproject.toml containing
[project]
name = "ml"
...
[tool.setuptools.packages.find]
where = ["."]
include = ["ml", "scripts"]
However, imports from the scripts directory don't typecheck correctly,
At runtime, it imports fine, so it's only an issue with the typechecker.
Also, interestingly, imports from ml directory work fine, it's only an issue with the introduction of a second directory to import from.
Also, executing touch ./scripts/__init__.py fixes it. But, __init__.py shouldn't be necessary based on PEP 420.
Workaround
Execute touch ./other_directory/__init__.py
Ideal
The typechecker finds the import without __init__.py
i can't reproduce this. could you provide some more info please:
- what version of basedpyright you're using
- is basedpyright running from the pypi package in your environment, or the version that comes bundled with the vscode extension?
- does the same thing happen in pyright or pylance?
- the contents of the
scriptsandmldirectories (themldirectory doesn't seem to be used in your example at all, is it actuaally needed as part of this minimal repro?) - what tool(s) you're using to manage your python environment (eg. uv, pip/virtualenv, etc)
closing this. if you are still experiencing this issue please provide the additional info mentioned above and we can re-open