Skip to content

Deprecate --strict-boolean and remove it from --strict #3197

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 2 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions docs/source/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ flag (or its long form ``--help``)::
[--inferstats] [--custom-typing MODULE]
[--custom-typeshed-dir DIR] [--scripts-are-modules]
[--config-file CONFIG_FILE] [--show-column-numbers]
[--find-occurrences CLASS.MEMBER] [--strict-boolean]
[--find-occurrences CLASS.MEMBER]
[--cobertura-xml-report DIR] [--html-report DIR]
[--linecount-report DIR] [--linecoverage-report DIR]
[--memory-xml-report DIR] [--old-html-report DIR]
Expand Down Expand Up @@ -366,11 +366,6 @@ Here are some more useful flags:
- ``--warn-return-any`` causes mypy to generate a warning when returning a value
with type ``Any`` from a function declared with a non- ``Any`` return type.

- ``--strict-boolean`` will make using non-boolean expressions in conditions
an error. This means ``if x`` and ``while x`` are disallowed when ``x`` has any
type other than ``bool``. Instead use explicit checks like ``if x > 0`` or
``while x is not None``.

- ``--strict`` mode enables all optional error checking flags. You can see the
list of flags enabled by strict mode in the full ``mypy -h`` output.

Expand Down
3 changes: 3 additions & 0 deletions docs/source/revision_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Revision history

List of major changes to this document:

- April 2017
* Remove option ``strict_boolean``.

- March 2017
* Publish ``mypy`` version 0.500 on PyPI.

Expand Down
7 changes: 5 additions & 2 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ def add_invertible_flag(flag: str,
parser.add_argument('--find-occurrences', metavar='CLASS.MEMBER',
dest='special-opts:find_occurrences',
help="print out all usages of a class member (experimental)")
add_invertible_flag('--strict-boolean', default=False, strict_flag=True,
help='enable strict boolean checks in conditions')
strict_help = "Strict mode. Enables the following flags: {}".format(
", ".join(strict_flag_names))
parser.add_argument('--strict', action='store_true', dest='special-opts:strict',
Expand All @@ -292,6 +290,8 @@ def add_invertible_flag(flag: str,
# --dump-graph will dump the contents of the graph of SCCs and exit.
parser.add_argument('--dump-graph', action='store_true', help=argparse.SUPPRESS)
# deprecated options
add_invertible_flag('--strict-boolean', default=False,
help=argparse.SUPPRESS)
parser.add_argument('-f', '--dirty-stubs', action='store_true',
dest='special-opts:dirty_stubs',
help=argparse.SUPPRESS)
Expand Down Expand Up @@ -364,6 +364,9 @@ def add_invertible_flag(flag: str,
)

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