diff --git a/mypy/checker.py b/mypy/checker.py index d9fb20aa3a00f..72c53f0500ab8 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -2693,11 +2693,6 @@ def visit_if_stmt(self, s: IfStmt) -> None: if isinstance(t, DeletedType): self.msg.deleted_as_rvalue(t, s) - if self.options.strict_boolean: - is_bool = isinstance(t, Instance) and t.type.fullname() == 'builtins.bool' - if not (is_bool or isinstance(t, AnyType)): - self.fail(messages.NON_BOOLEAN_IN_CONDITIONAL, e) - if_map, else_map = self.find_isinstance_check(e) # XXX Issue a warning if condition is always False? diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 95a4ecdf2c1a4..2d0a2b9ca5e38 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -2930,11 +2930,6 @@ def check_for_comp(self, e: Union[GeneratorExpr, DictionaryComprehension]) -> No def visit_conditional_expr(self, e: ConditionalExpr) -> Type: cond_type = self.accept(e.cond) - if self.chk.options.strict_boolean: - is_bool = (isinstance(cond_type, Instance) - and cond_type.type.fullname() == 'builtins.bool') - if not (is_bool or isinstance(cond_type, AnyType)): - self.chk.fail(messages.NON_BOOLEAN_IN_CONDITIONAL, e) ctx = self.type_context[-1] # Gain type information from isinstance if it is there diff --git a/mypy/main.py b/mypy/main.py index 44f3011169a5e..86cf12330b351 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -689,11 +689,10 @@ def add_invertible_flag(flag: str, help=argparse.SUPPRESS) # deprecated options - add_invertible_flag('--strict-boolean', default=False, - help=argparse.SUPPRESS) parser.add_argument('--quick-and-dirty', action='store_true', help=argparse.SUPPRESS) + # options specifying code to check code_group = parser.add_argument_group( title="Running code", description="Specify the code you want to type check. For more details, see " @@ -739,9 +738,6 @@ def add_invertible_flag(flag: str, parser.parse_args(args, SplitNamespace(options, special_opts, 'special-opts:')) # 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 options.quick_and_dirty: print("Warning: --quick-and-dirty is deprecated. It will disappear in the next release.", file=sys.stderr) diff --git a/mypy/messages.py b/mypy/messages.py index 5800c4fc20a5f..2162c06acbf01 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -101,7 +101,6 @@ TYPEDDICT_KEY_MUST_BE_STRING_LITERAL = \ 'Expected TypedDict key to be string literal' # type: Final MALFORMED_ASSERT = 'Assertion is always true, perhaps remove parentheses?' # type: Final -NON_BOOLEAN_IN_CONDITIONAL = 'Condition must be a boolean' # type: Final DUPLICATE_TYPE_SIGNATURES = 'Function has duplicate type signatures' # type: Final GENERIC_INSTANCE_VAR_CLASS_ACCESS = \ 'Access to generic instance variables via class is ambiguous' # type: Final diff --git a/mypy/options.py b/mypy/options.py index a9743deea97ce..7388c241f9a29 100644 --- a/mypy/options.py +++ b/mypy/options.py @@ -43,7 +43,6 @@ class BuildType: "mypyc", "no_implicit_optional", "show_none_errors", - "strict_boolean", "strict_optional", "strict_optional_whitelist", "warn_no_return", @@ -131,9 +130,6 @@ def __init__(self) -> None: # Files in which to ignore all non-fatal errors self.ignore_errors = False - # Only allow booleans in conditions - self.strict_boolean = False - # Apply strict None checking self.strict_optional = True