You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report
I'm currently attempting to run mypy on a new project I'm setting up for my company. It has a dependency on a shared module which in its current state is not ready for type checking. Ideally I could just have mypy ignore that module, however I'm having some difficulty due to a perhaps somewhat unusual structure (described below). Fundamentally, the issue is a file named 'config.py' next to a directory name 'config' in the same location. This causes mypy to read the wrong "submodule", which would be fine for now, if not for that fact that it also cannot be ignored with follow_imports=skip. This results in an error in my project error: Module "shared_module.config" has no attribute "CONFIG"
Expected Behavior
Mypy sees the import from shared_module.config import CONFIG, treats it as Any, and moves along
Mypy sees the import from shared_module.foobar import DOESNT_EXIST, treats it as Any, and moves along
Actual Behavior
Mypy sees the import from shared_module.foobar import DOESNT_EXIST, treats it as Any, and moves along exactly what I was hoping for (sanity checks that my ini file is setup correctly, obviously wont actually run in python)
Mypy sees the import from shared_module.config import CONFIG, does not ignore it, and additionally attempts to find CONFIG in the config folder, rather than config.py (The python interpreter correctly imports from config.py)
both are problems, but the former (not ignoring my import) is my primary concern for now.
In the short term, I can use # type: ignore on my imports but this is far from ideal
$ mypy this_works.py
Success: no issues found in 1 source file
$ mypy this_breaks.py
this_breaks.py:1: error: Module "shared_module.config" has no attribute "CONFIG"
Found 1 error in 1 file (checked 1 source file)
Your Environment
macOS 12.6, conda
Mypy version used: 0.91, 0.981
Mypy command-line flags: (none, see ini file)
Mypy configuration options from mypy.ini (and other config files): (see above)
Python version used: 3.8.8, 3.8.13
The text was updated successfully, but these errors were encountered:
Thanks for the quick reply, that workaround works great. Any thoughts on why mypy is picking up the empty directory instead of the file, while the python interpreter does it the other way around? (Although to be fair, I'm not sure if this is well defined behavior for python anyways)
Bug Report
I'm currently attempting to run mypy on a new project I'm setting up for my company. It has a dependency on a shared module which in its current state is not ready for type checking. Ideally I could just have mypy ignore that module, however I'm having some difficulty due to a perhaps somewhat unusual structure (described below). Fundamentally, the issue is a file named 'config.py' next to a directory name 'config' in the same location. This causes mypy to read the wrong "submodule", which would be fine for now, if not for that fact that it also cannot be ignored with follow_imports=skip. This results in an error in my project
error: Module "shared_module.config" has no attribute "CONFIG"
To Reproduce
mypy-repro.zip
I've attached a minimal repro project, but here is a summary:
Project Structure
config.py
foobar.py (empty file)
this_breaks.py
this_works.py
mypy.ini
Expected Behavior
Mypy sees the import
from shared_module.config import CONFIG
, treats it as Any, and moves alongMypy sees the import
from shared_module.foobar import DOESNT_EXIST
, treats it as Any, and moves alongActual Behavior
Mypy sees the import
from shared_module.foobar import DOESNT_EXIST
, treats it as Any, and moves along exactly what I was hoping for (sanity checks that my ini file is setup correctly, obviously wont actually run in python)Mypy sees the import
from shared_module.config import CONFIG
, does not ignore it, and additionally attempts to find CONFIG in the config folder, rather than config.py (The python interpreter correctly imports from config.py)both are problems, but the former (not ignoring my import) is my primary concern for now.
I have also tried these to no avail
In the short term, I can use # type: ignore on my imports but this is far from ideal
Your Environment
macOS 12.6, conda
mypy.ini
(and other config files): (see above)The text was updated successfully, but these errors were encountered: