When given directory mypy only analyzes files with PY_EXTENSIONS
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
I have a Python script with __main__ in a file that has no extension
When the file is supplied to mypy directly it can evaluate it due to the code found here.
❯ mypy --scripts-are-modules --strict tools/docker2sqlelf | head
tools/docker2sqlelf:10: error: Skipping analyzing "docker": module is installed, but missing library stubs or py.typed marker [import-untyped]
tools/docker2sqlelf:10: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
tools/docker2sqlelf:21: error: Function is missing a return type annotation [no-untyped-def]
tools/docker2sqlelf:21: note: Use "-> None" if function does not return a value
tools/docker2sqlelf:75: error: Incompatible return value type (got "str", expected "int") [return-value]
Found 3 errors in 1 file (checked 1 source file)
However if I give the directory the file is in, it is skipped due to the logic in find_sources_in_dir.
❯ mypy --scripts-are-modules --strict tools | head
Success: no issues found in 1 source file
Here is the contents of the directory tools:
❯ tree tools
tools
├── debian-unstable-tags.txt
├── docker2sqlelf
├── __init__.py
├── README.md
└── unstable2sqlelf
1 directory, 5 files
- Mypy version used:
❯ mypy --version
mypy 1.8.0 (compiled: yes)
- Python version used: 3.10 and 3.11
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
Inspect mypy/find_sources.py, starting with the direct-file handling near the linked code and find_sources_in_dir. Reproduce the difference with mypy --scripts-are-modules --strict tools/docker2sqlelf and with tools, then verify that directory analysis includes extensionless Python scripts while preserving the reported diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100