-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add option to selectively disable --disallow-untyped-calls #15845
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,7 +490,38 @@ section of the command line docs. | |
:default: False | ||
|
||
Disallows calling functions without type annotations from functions with type | ||
annotations. | ||
annotations. Note that when used in per-module options, it enables/disables | ||
this check **inside** the module(s) specified, not for functions that come | ||
from that module(s), for example config like this: | ||
|
||
.. code-block:: ini | ||
|
||
[mypy] | ||
disallow_untyped_calls = True | ||
|
||
[mypy-some.library.*] | ||
disallow_untyped_calls = False | ||
|
||
will disable this check inside ``some.library``, not for your code that | ||
imports ``some.library``. If you want to selectively disable this check for | ||
all your code that imports ``some.library`` you should instead use | ||
:confval:`untyped_call_exception`, for example: | ||
|
||
.. code-block:: ini | ||
|
||
[mypy] | ||
disallow_untyped_calls = True | ||
untyped_call_exception = some.library | ||
|
||
.. confval:: untyped_call_exception | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems useful, but I'm not sure about the name of the option. Maybe we can come up with a better name? I don't any suggestions right now, but I'll think about this later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also struggled some time with this. I would propose to not spend much time on this. People who want this will probably search for "mypy untyped call" or similar, so including these words in the option name should be good enough. So if you have a better idea, then I will be happy to update, otherwise let's just move on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fwiw I'd go with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what I considered at first, but then how wold we call corresponding command line option? |
||
|
||
:type: comma-separated list of strings | ||
|
||
Selectively excludes functions and methods defined in specific packages, | ||
modules, and classes from action of :confval:`disallow_untyped_calls`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mention that this also applies to submodules of packages (i.e. everything inside that prefix). |
||
This also applies to all submodules of packages (i.e. everything inside | ||
a given prefix). Note, this option does not support per-file configuration, | ||
the exception list is defined globally for all your code. | ||
|
||
.. confval:: disallow_untyped_defs | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numpy's probably not a great example here, as they ship with a
py.typed
file these days and have pretty complete type annotations. Maybe one ofmatplotlib
,requests
orTensorFlow
might be a better example? Third-party stubs exist for all three packages, but none of them ships with apy.typed
fileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any example of a popular library might become a bad example over time, maybe limit ourselves to something generic like
third_party_lib
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's use some generic name.