Skip to content

Commit 064c8d3

Browse files
authored
Don't call --strict-optional and --incremental experimental (#4642)
Also stop documenting strict_optional_whitelist, since it has been long since obsoleted, with the idea of removing it soon.
1 parent 80c95ea commit 064c8d3

File tree

2 files changed

+23
-35
lines changed

2 files changed

+23
-35
lines changed

docs/source/command_line.rst

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,11 @@ Here are some more useful flags:
292292
- ``--ignore-missing-imports`` suppresses error messages about imports
293293
that cannot be resolved (see :ref:`follow-imports` for some examples).
294294

295-
- ``--strict-optional`` enables experimental strict checking of ``Optional[...]``
296-
types and ``None`` values. Without this option, mypy doesn't generally check the
297-
use of ``None`` values -- they are valid everywhere. See :ref:`strict_optional` for
298-
more about this feature.
299-
300-
- ``--strict-optional-whitelist`` attempts to suppress strict Optional-related
301-
errors in non-whitelisted files. Takes an arbitrary number of globs as the
302-
whitelist. This option is intended to be used to incrementally roll out
303-
``--strict-optional`` to a large codebase that already has mypy annotations.
304-
However, this flag comes with some significant caveats. It does not suppress
305-
all errors caused by turning on ``--strict-optional``, only most of them, so
306-
there may still be a bit of upfront work to be done before it can be used in
307-
CI. It will also suppress some errors that would be caught in a
308-
non-strict-Optional run. Therefore, when using this flag, you should also
309-
re-check your code without ``--strict-optional`` to ensure new type errors
310-
are not introduced.
295+
- ``--strict-optional`` enables strict checking of ``Optional[...]``
296+
types and ``None`` values. Without this option, mypy doesn't
297+
generally check the use of ``None`` values -- they are valid
298+
everywhere. See :ref:`strict_optional` for more about this feature.
299+
This flag will become the default in the near future.
311300

312301
- ``--disallow-untyped-defs`` reports an error whenever it encounters
313302
a function definition without type annotations.
@@ -342,17 +331,19 @@ Here are some more useful flags:
342331

343332
.. _incremental:
344333

345-
- ``--incremental`` is an experimental option that enables a module
346-
cache. When enabled, mypy caches results from previous runs
347-
to speed up type checking. Incremental mode can help when most parts
348-
of your program haven't changed since the previous mypy run. A
349-
companion flag is ``--cache-dir DIR``, which specifies where the
350-
cache files are written. By default this is ``.mypy_cache`` in the
351-
current directory. While the cache is only read in incremental
352-
mode, it is written even in non-incremental mode, in order to "warm"
353-
the cache. To disable writing the cache, use
354-
``--cache-dir=/dev/null`` (UNIX) or ``--cache-dir=nul`` (Windows).
355-
Cache files belonging to a different mypy version are ignored.
334+
- ``--incremental`` enables a module cache, using results from
335+
previous runs to speed up type checking. Incremental mode can help
336+
when most parts of your program haven't changed since the previous
337+
mypy run.
338+
339+
- ``--cache-dir DIR`` is a companion flag to ``-incremental``, which
340+
specifies where the cache files are written. By default this is
341+
``.mypy_cache`` in the current directory. While the cache is only
342+
read in incremental mode, it is written even in non-incremental
343+
mode, in order to "warm" the cache. To disable writing the cache,
344+
use ``--cache-dir=/dev/null`` (UNIX) or ``--cache-dir=nul``
345+
(Windows). Cache files belonging to a different mypy version are
346+
ignored.
356347

357348
.. _quick-mode:
358349

docs/source/kinds_of_types.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,14 @@ idiomatic.
432432

433433
.. _strict_optional:
434434

435-
Experimental strict optional type and None checking
435+
Strict optional type and None checking
436436
***************************************************
437437

438438
Currently, ``None`` is a valid value for each type, similar to
439439
``null`` or ``NULL`` in many languages. However, you can use the
440-
experimental ``--strict-optional`` command line option to tell mypy
441-
that types should not include ``None``
440+
``--strict-optional`` command line option
441+
(which will become the default in the near future)
442+
to tell mypy that types should not include ``None``
442443
by default. The ``Optional`` type modifier is then used to define
443444
a type variant that includes ``None``, such as ``Optional[int]``:
444445

@@ -478,10 +479,6 @@ recognizes ``is None`` checks:
478479
Mypy will infer the type of ``x`` to be ``int`` in the else block due to the
479480
check against ``None`` in the if condition.
480481

481-
.. note::
482-
483-
``--strict-optional`` is experimental and still has known issues.
484-
485482
.. _noreturn:
486483

487484
The NoReturn type
@@ -986,7 +983,7 @@ annotated the first example as the following:
986983
def squares(n: int) -> Generator[int, None, None]:
987984
for i in range(n):
988985
yield i * i
989-
986+
990987
This is slightly different from using ``Iterable[int]`` or ``Iterator[int]``,
991988
since generators have ``close()``, ``send()``, and ``throw()`` methods that
992989
generic iterables don't. If you will call these methods on the returned

0 commit comments

Comments
 (0)