-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add option to selectively disable --disallow-untyped-calls #15845
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
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
| :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`. | ||
|
Collaborator
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 | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw I'd go with
untyped_call_allowlist. Clearly conveys the type as well ;-)Uh oh!
There was an error while loading. Please reload this page.
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.
This is what I considered at first, but then how wold we call corresponding command line option?
--untyped-call-allowlist? All other options like--always-true,--always-false,--enable-error-code,--disable-error-codeetc, are singular and should be repeated. So I would say we should try to follow this pattern. Finally, from reading comments in the issue, it looks like most people will need just 1 or maybe 2 exceptions, not more.