I'm trying to set up mypy type checking for a project. I want to exclude a bunch of files/directories to start so that we can at least enforce that type checking passes on new code, then we can burn down the exclude list over time. Unfortunately mypy is ignoring my exclude configuration and I can't figure out why.
I've created a mypy.ini
config file with the following content:
[mypy]
python_version = 3.8
exclude = /examples/
But when I run mypy --verbose .
, it still discovers and errors on files in that directory. The log messages tell me it is seeing my exclude configuration but apparently ignoring it:
LOG: Mypy Version: 0.812
LOG: Config File: mypy.ini
LOG: Configured Executable: /Library/Developer/CommandLineTools/usr/bin/python
3
LOG: Current Executable: /Library/Developer/CommandLineTools/usr/bin/python
3
LOG: Cache Dir: .mypy_cache
LOG: Compiled: True
LOG: Exclude: /examples/
<snipped>
LOG: Found source: BuildSource(path='./examples/fib.py', module='fib', has_text=False, base_dir='/Users/user/a/examples')
LOG: Found source: BuildSource(path='./examples/fib_iter.py', module='fib_iter', has_text=False, base_dir='/Users/user/a/examples')
<snipped>
examples/fib.py: error: Duplicate module named 'fib' (also at './examples/a/fib.py')
examples/fib.py: note: Are you missing an __init__.py? Alternatively, consider using --exclude to avoid checking one of them.
Found 1 error in 1 file (errors prevented further checking)
Why is my exclude configuration not working?