0.800: Unable to configure subdirectories
In Mypy 0.800, it now checks files in subdirectories without __init__.py files.
The problem is that the config still only works on modules containing __init__.py, meaning there is no way to change the config for these subdirectories.
e.g. untyped-def errors have started appearing in test/foo/bar.py
Adding this to config has no effect:
[mypy-tests.*]
disallow_untyped_defs = False
This only works if tests/__init__.py and tests/foo/__init__.py are created.
Expected behaviour is that the above config will ignore the errors, or an alternative syntax is available to do so (e.g. [mypy-tests/*].
I marked this as a bug, as it's kind of a regression from 0.790, in that files checked by default cannot be configured.
I reported something similar in #9974.
You can (as previously) use the module name mypy associates with the file, so e.g. [mypy-bar] will let you ignore tests/foo/bar.py. Exactly as if you'd run mypy tests/foo/bar.py with mypy 0.790.
So fwiw I'd classify this as a feature request. Do see #9974 though :-)
I think if --namespace-packages is made default as mentioned in that issue, that would resolve the "regression".
This would still be useful to support though as it makes it easier to include tests and examples in the checks (which normally need less strict options configured). Currently this requires adding a bunch of __init__.py files which don't really make sense in this context, they are added purely to make Mypy work.
Is this likely to get implemented in an upcoming release? Or is the recommendation to litter the codebase with __init__.py for now? (Just figuring out if it's worth waiting a bit longer before upgrading or not).
--namespace-packages is the default in the next release
I'm not sure this quite resolves the situation. It seems that I can still only configure directories if there is a __init__.py in the top-level directory.
I'm figuring out how to configure https://github.com/aio-libs/aiohttp-demos/
But, the default behaviour means that I can only configure individual paths with the presence of __init__.py in demos/. Which then gets more complicated as you end with Source file found twice under different module names errors.
So, it seems you still can't do configuration for all paths that mypy reports errors on in 0.800+.
It seems to me like module discovery for imports and configuration paths are intertwined. So, I'm struggling to get mypy to check the files for individual demos and recognise the import aiohttpdemo_blog etc. imports and be able to configure strictness for individual demos/paths.
If anybody has any ideas how to make this work currently, that would be great. My initial attempt is at: https://github.com/aio-libs/aiohttp-demos/pull/210/files
I'd like mypy to type check all the demos, while being able to configure the settings for each demo individually. This just seems to be impossible currently.
Can someone point me out what I need to look code wise to fix this?