mypy.ini parsing trailing comma causes duplicate module error #11171
Open
Description
Documentation
I've opted for documentation
but this could just as well have been a bug report or a feature request. The issue is with a trailing comma after the last file in a list of files in mypy.ini
. e.g.:
[mypy]
files =
myproject/package1,
myproject/package2,
myproject/module1.py,
myproject/module2.py,
This results in a duplicate module error as follows:
myproject/package1/__init__.py: error: Duplicate module named "myproject.package1" (also at "myproject/package1/__init__.py")
myproject/package1/__init__.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)
It appears to somehow read the first element in the list again. Both packages already have __init__.py
files. The problem is that this error isn't very informative and it took me a while to realise this was the cause.
Possible solutions:
- Document this here
- Detect trailing comma and flag this to user instead of parsing the config file and returning a cryptic error
- Ignore trailing commas for the final element of a list during parsing of the config file
mypy==0.910