为什么 mypy 检查我排除的文件?

时间:2021-04-16 19:07:55

标签: python mypy

我正在尝试为项目设置 mypy 类型检查。我想排除一堆文件/目录来启动,这样我们至少可以强制执行新代码的类型检查,然后我们可以随着时间的推移销毁排除列表。不幸的是,mypy 忽略了我的排除配置,我不知道为什么。

我创建了一个包含以下内容的 mypy.ini 配置文件:

[mypy]
python_version = 3.8
exclude = /examples/

但是当我运行 mypy --verbose . 时,它仍然会发现该目录中的文件并出现错误。日志消息告诉我它正在查看我的排除配置,但显然忽略了它:

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)

为什么我的排除配置不起作用?

0 个答案:

没有答案
相关问题