Skip to content

Commit 71c7b57

Browse files
pkchgvanrossum
authored andcommitted
Deprecate --strict-boolean and remove it from --strict (#3197)
* Deprecate and remove --strict-boolean from --strict * Update docs
1 parent cc24f5b commit 71c7b57

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

docs/source/command_line.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ flag (or its long form ``--help``)::
2121
[--inferstats] [--custom-typing MODULE]
2222
[--custom-typeshed-dir DIR] [--scripts-are-modules]
2323
[--config-file CONFIG_FILE] [--show-column-numbers]
24-
[--find-occurrences CLASS.MEMBER] [--strict-boolean]
24+
[--find-occurrences CLASS.MEMBER]
2525
[--cobertura-xml-report DIR] [--html-report DIR]
2626
[--linecount-report DIR] [--linecoverage-report DIR]
2727
[--memory-xml-report DIR] [--old-html-report DIR]
@@ -366,11 +366,6 @@ Here are some more useful flags:
366366
- ``--warn-return-any`` causes mypy to generate a warning when returning a value
367367
with type ``Any`` from a function declared with a non- ``Any`` return type.
368368

369-
- ``--strict-boolean`` will make using non-boolean expressions in conditions
370-
an error. This means ``if x`` and ``while x`` are disallowed when ``x`` has any
371-
type other than ``bool``. Instead use explicit checks like ``if x > 0`` or
372-
``while x is not None``.
373-
374369
- ``--strict`` mode enables all optional error checking flags. You can see the
375370
list of flags enabled by strict mode in the full ``mypy -h`` output.
376371

docs/source/revision_history.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Revision history
33

44
List of major changes to this document:
55

6+
- April 2017
7+
* Remove option ``strict_boolean``.
8+
69
- March 2017
710
* Publish ``mypy`` version 0.500 on PyPI.
811

mypy/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ def add_invertible_flag(flag: str,
272272
parser.add_argument('--find-occurrences', metavar='CLASS.MEMBER',
273273
dest='special-opts:find_occurrences',
274274
help="print out all usages of a class member (experimental)")
275-
add_invertible_flag('--strict-boolean', default=False, strict_flag=True,
276-
help='enable strict boolean checks in conditions')
277275
strict_help = "Strict mode. Enables the following flags: {}".format(
278276
", ".join(strict_flag_names))
279277
parser.add_argument('--strict', action='store_true', dest='special-opts:strict',
@@ -292,6 +290,8 @@ def add_invertible_flag(flag: str,
292290
# --dump-graph will dump the contents of the graph of SCCs and exit.
293291
parser.add_argument('--dump-graph', action='store_true', help=argparse.SUPPRESS)
294292
# deprecated options
293+
add_invertible_flag('--strict-boolean', default=False,
294+
help=argparse.SUPPRESS)
295295
parser.add_argument('-f', '--dirty-stubs', action='store_true',
296296
dest='special-opts:dirty_stubs',
297297
help=argparse.SUPPRESS)
@@ -364,6 +364,9 @@ def add_invertible_flag(flag: str,
364364
)
365365

366366
# Process deprecated options
367+
if options.strict_boolean:
368+
print("Warning: --strict-boolean is deprecated; "
369+
"see https://github.com/python/mypy/issues/3195", file=sys.stderr)
367370
if special_opts.almost_silent:
368371
print("Warning: --almost-silent has been replaced by "
369372
"--follow-imports=errors", file=sys.stderr)

0 commit comments

Comments
 (0)