Open captain-kark opened 4 years ago
As it stands, right now this pull request will only resolve any errors coming from mypy saying it can't find your module's type definitions in your current test file, but actual type checking isn't working. I'm investigating a couple of issues with my setup/project and determining which of the following could be causing issues with the behavior I'm seeing versus what I would expect:
my some_project
module only contains an init/main python file and isn't type checking anything at all unless I start passing arguments into the top-level function I am invoking immediately after checking if __name__ == '__main__'
. I am pretty certain I can reduce this into a bug report that can be demonstrated with mypy -c '...'
soon.
my tests directory is able to import a valid some_project
method member and detect issues from pylint, but mypy still isn't complaining when I, for instance, pass a single int to a function signature requiring a str.
moving functions into a lib.py
outside of __init__.py
isn't helping
I've been looking into modifying _base_flags
for mypy, using --scripts-are-modules
, --follow-imports=error
, etc. Any of the source files provided to help tests run mypy type checks have also been passed in using -m
or -p
, which has led me to suspect that I may be misusing mypy.
I'll be making a some_project/lib/__init__.py
module and repeat all of these steps, and next. If that doesn't work, I'll drop the __main__.py
entirely and move everything out of __init__.py
so that it only imports from sibling module definitions. If there still isn't any progress on getting type checking working in my tests, I'll look into either moving my tests into the module source directly, and later, seeing if there's any special edge cases needed when using mypy in a directory that's expected to host pytest runners.
Any of this ringing a bell for you? Any ideas what I might be doing wrong, or why I might be having issues getting mypy to return false positives like this?
I am working in a project where all tests are placed in a sibling directory next to the main project's source root.
If you include a
mypy_path
inmypy.ini
pointing to your current project, when combined withfind_project_root
, a check can be made to use your project's existing mypy type definitions while editing code in thetests
directory.When editing code that matches a directory that shares its base with a
mypy_path
, nothing is done since it is already in mypy's context.