Skip to content

Commit 581e514

Browse files
Michael0x2agvanrossum
authored andcommitted
Recategorize and document --warn-incomplete-stub (#5555)
* Recategorize and document --warn-incomplete-stub Previously, the `--warn-incomplete-stub` flag was inconsistently documented: it was missing from the "Mypy command line" section of the docs, but was documented in the "Mypy configuration file" section and appeared under "Untyped definitions and calls" section when running `mypy --help`. This pull request: 1. Adds documentation for this flag to the command line docs. 2. Recategorizes the flag to fall under "Mypy internals" -- I can't really see people other then typeshed contributors finding this flag useful. 3. Updates the docs so it states this flag is useful only when using `--disallow-incomplete-defs` or `--disallow-untyped-defs` instead of `--check-untyped-defs`. This option appears to be used [only once in checker.py][0] -- the `check_untyped_defs` option does not seem relevant there. [0]: https://github.com/python/mypy/blob/master/mypy/checker.py#L947
1 parent 0e4c869 commit 581e514

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

docs/source/command_line.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,21 @@ in developing or debugging mypy internals.
465465
submitting them upstream, but also allows you to use a forked version of
466466
typeshed.
467467

468+
``--warn-incomplete-stub``
469+
This flag modifies both the ``--disallow-untyped-defs`` and
470+
``--disallow-incomplete-defs`` flags so they also report errors
471+
if stubs in typeshed are missing type annotations or has incomplete
472+
annotations. If both flags are missing, ``--warn-incomplete-stub``
473+
also does nothing.
474+
475+
This flag is mainly intended to be used by people who want contribute
476+
to typeshed and would like a convenient way to find gaps and omissions.
477+
478+
If you want mypy to report an error when your codebase *uses* an untyped
479+
function, whether that function is defined in typeshed or not, use the
480+
``--disallow-untyped-call`` flag. See :ref:`untyped-definitions-and-calls`
481+
for more details.
482+
468483
.. _shadow-file:
469484

470485
``--shadow-file SOURCE_FILE SHADOW_FILE``

docs/source/config_file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ The following global flags may only be set in the global section
103103

104104
- ``warn_incomplete_stub`` (Boolean, default False) warns for missing
105105
type annotation in typeshed. This is only relevant in combination
106-
with ``check_untyped_defs``.
106+
with ``disallow_untyped_defs`` or ``disallow_incomplete_defs``.
107107

108108
- ``warn_redundant_casts`` (Boolean, default False) warns about
109109
casting an expression to its inferred type.

mypy/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,6 @@ def add_invertible_flag(flag: str,
512512
add_invertible_flag('--check-untyped-defs', default=False, strict_flag=True,
513513
help="Type check the interior of functions without type annotations",
514514
group=untyped_group)
515-
add_invertible_flag('--warn-incomplete-stub', default=False,
516-
help="Warn if missing type annotation in typeshed, only relevant with"
517-
" --check-untyped-defs enabled",
518-
group=untyped_group)
519515
add_invertible_flag('--disallow-untyped-decorators', default=False, strict_flag=True,
520516
help="Disallow decorating typed functions with untyped decorators",
521517
group=untyped_group)
@@ -608,6 +604,10 @@ def add_invertible_flag(flag: str,
608604
internals_group.add_argument(
609605
'--custom-typeshed-dir', metavar='DIR',
610606
help="Use the custom typeshed in DIR")
607+
add_invertible_flag('--warn-incomplete-stub', default=False,
608+
help="Warn if missing type annotation in typeshed, only relevant with"
609+
" --disallow-untyped-defs or --disallow-incomplete-defs enabled",
610+
group=internals_group)
611611
internals_group.add_argument(
612612
'--shadow-file', nargs=2, metavar=('SOURCE_FILE', 'SHADOW_FILE'),
613613
dest='shadow_file', action='append',

0 commit comments

Comments
 (0)