Cannot exclude __init__.py without excluding the entire dir
Open
Nobody has claimed this yet.
bug
topic-configuration
topic-usability
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
To Reproduce
$ mkdir foo
$ cd foo
$ mkdir testpkg
$ echo "def f(): pass" > testpkg/__init__.py
$ echo "def g(): pass" > testpkg/foo.py
$ mypy --disallow-untyped-defs --exclude "fo" testpkg # <--- excludes foo.py
testpkg/__init__.py:1: error: Function is missing a return type annotation
testpkg/__init__.py:1: note: Use "-> None" if function does not return a value
Found 1 error in 1 file (checked 1 source file)
$ mypy --disallow-untyped-defs --exclude "init" testpkg # <---- should exclude __init__.py
testpkg/__init__.py:1: error: Function is missing a return type annotation
testpkg/__init__.py:1: note: Use "-> None" if function does not return a value
testpkg/foo.py:1: error: Function is missing a return type annotation
testpkg/foo.py:1: note: Use "-> None" if function does not return a value
Found 2 errors in 2 files (checked 1 source file)
Expected Behavior
__init__.py should be ignored in the last command
Actual Behavior
__init__.py was not ignored in the last command
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: see above
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.7.3
- Operating system and version: Debian 10
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
Reproduce the two mypy commands using testpkg/init.py and testpkg/foo.py, comparing the --exclude "fo" and --exclude "init" results. Trace how the exclude pattern is applied to discovered files, then add coverage showing that __init__.py is ignored by the latter pattern while foo.py remains checked.
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