8000 Emphasise that users probably want --follow-imports=normal by hauntsaninja · Pull Request #9955 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Emphasise that users probably want --follow-imports=normal #9955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Emphasise that users probably want --follow-imports=normal
For whatever reason, these options get misused a lot and cause a lot of
problems. #9954 is only the latest in a long history of
misunderstanding.

I speculate that this is because of a) the bad legacy of flake8-mypy,
b) people confusing it with ignore_missing_imports
  • Loading branch information
hauntsaninja committed Jan 24, 2021
commit fc59213ab166711da3f41a5d3055cb092eba2aab
9 changes: 5 additions & 4 deletions docs/source/running_mypy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,12 @@ the former has type hints and the latter does not. We run
:option:`mypy -m mycode.foo <mypy -m>` and mypy discovers that ``mycode.foo`` imports
``mycode.bar``.

How do we want mypy to type check ``mycode.bar``? We can configure the
desired behavior by using the :option:`--follow-imports <mypy --follow-imports>` flag. This flag
How do we want mypy to type check ``mycode.bar``? Mypy's behaviour here is
configurable -- although we **strongly recommend** using the default --
by using the :option:`--follow-imports <mypy --follow-imports>` flag. This flag
accepts one of four string values:

- ``normal`` (the default) follows all imports normally and
- ``normal`` (the default, recommended) follows all imports normally and
type checks all top level code (as well as the bodies of all
functions and methods with at least one type annotation in
the signature).
Expand Down Expand Up @@ -328,7 +329,7 @@ files that do not use type hints) pass under :option:`--follow-imports=normal <m
This is usually not too difficult to do: mypy is designed to report as
few error messages as possible when it is looking at unannotated code.

If doing this is intractable, we recommend passing mypy just the files
Only if doing this is intractable, we recommend passing mypy just the files
you want to type check and use :option:`--follow-imports=silent <mypy --follow-imports>`. Even if
mypy is unable to perfectly type check a file, it can still glean some
useful information by parsing it (for example, understanding what methods
Expand Down
0