Ignore CWD for explicit package bases
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
Add an option (name TBD) to ignore the current directory when looking for namespace package bases.
As far as I can tell, the behavior would have to be modified here (optionally leaving out [os.getcwd()]: https://github.com/python/mypy/blob/695ea3017fee084c9d2ec17d9b28f8af905e3b63/mypy/find_sources.py#L87
Pitch
When type-checking a repository with src/ structure, there can be conflicts between installed Python modules, and directories which are located at the root of the repository (assuming that is the CWD for running mypy).
I stumbled upon this by having a directory called docker/, while also having https://pypi.org/project/docker/ installed.
As far as I could tell, there's currently no satisfactory way for mypy to accept this, besides renaming the directory.
Happy to take a stab at implementing this, if you feel it's worth adding.
Related discussion: #8584
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in mypy/find_sources.py around line 87, where the current directory is included when finding namespace package bases. Read related discussion #8584 before deciding how the new option should be named and scoped. Done means an explicit package-base configuration can ignore the current directory without losing the intended source discovery behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100