Skip to content
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

Remove deprecated options #5740

Merged
merged 6 commits into from
Oct 5, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/source/running_mypy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ accepts one of four string values:
replace the module (and *anything imported from it*) with an
object of type ``Any``.

(Note: this option used to be known as ``--silent-imports``.)

- ``error`` behaves in the same way as ``skip`` but is not quite as
silent -- it will flag the import as an error, like this::

Expand Down
5 changes: 0 additions & 5 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
7 changes: 1 addition & 6 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2929,12 +2929,7 @@ def check_for_comp(self, e: Union[GeneratorExpr, DictionaryComprehension]) -> No
self.chk.binder.put(var, type)

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)
self.accept(e.cond)
ctx = self.type_context[-1]

# Gain type information from isinstance if it is there
Expand Down
57 changes: 1 addition & 56 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,30 +689,10 @@ def add_invertible_flag(flag: str,
help=argparse.SUPPRESS)

# deprecated options
parser.add_argument('--disallow-any', dest='special-opts:disallow_any',
help=argparse.SUPPRESS)
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)
parser.add_argument('--use-python-path', action='store_true',
dest='special-opts:use_python_path',
help=argparse.SUPPRESS)
parser.add_argument('-s', '--silent-imports', action='store_true',
dest='special-opts:silent_imports',
help=argparse.SUPPRESS)
parser.add_argument('--almost-silent', action='store_true',
dest='special-opts:almost_silent',
help=argparse.SUPPRESS)
parser.add_argument('--fast-parser', action='store_true', dest='special-opts:fast_parser',
help=argparse.SUPPRESS)
parser.add_argument('--no-fast-parser', action='store_true',
dest='special-opts:no_fast_parser',
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 "
Expand Down Expand Up @@ -757,42 +737,7 @@ def add_invertible_flag(flag: str,
special_opts = argparse.Namespace()
parser.parse_args(args, SplitNamespace(options, special_opts, 'special-opts:'))

# --use-python-path is no longer supported; explain why.
if special_opts.use_python_path:
parser.error("Sorry, --use-python-path is no longer supported.\n"
"If you are trying this because your code depends on a library module,\n"
"you should really investigate how to obtain stubs for that module.\n"
"See https://github.com/python/mypy/issues/1411 for more discussion."
)

# Process deprecated options
if special_opts.disallow_any:
print("--disallow-any option was split up into multiple flags. "
"See http://mypy.readthedocs.io/en/latest/command_line.html#disallow-dynamic-typing",
file=sys.stderr)
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)
if options.follow_imports == 'normal':
options.follow_imports = 'errors'
elif special_opts.silent_imports:
print("Warning: --silent-imports has been replaced by "
"--ignore-missing-imports --follow-imports=skip", file=sys.stderr)
options.ignore_missing_imports = True
if options.follow_imports == 'normal':
options.follow_imports = 'skip'
if special_opts.dirty_stubs:
print("Warning: -f/--dirty-stubs is deprecated and no longer necessary. Mypy no longer "
"checks the git status of stubs.",
file=sys.stderr)
if special_opts.fast_parser:
print("Warning: --fast-parser is now the default (and only) parser.")
if special_opts.no_fast_parser:
print("Warning: --no-fast-parser no longer has any effect. The fast parser "
"is now mypy's default and only parser.", 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)
Expand Down
1 change: 0 additions & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class BuildType:
"mypyc",
"no_implicit_optional",
"show_none_errors",
"strict_boolean",
"strict_optional",
"strict_optional_whitelist",
"warn_no_return",
Expand Down Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions test-data/unit/check-async-await.test
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async def f() -> None:
[typing fixtures/typing-full.pyi]

[case testAsyncForComprehension]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import Generic, Iterable, TypeVar, AsyncIterator, Tuple

T = TypeVar('T')
Expand Down Expand Up @@ -223,7 +223,7 @@ async def generatorexp(obj: Iterable[int]):
[typing fixtures/typing-full.pyi]

[case testAsyncForComprehensionErrors]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import Generic, Iterable, TypeVar, AsyncIterator, Tuple

T = TypeVar('T')
Expand Down Expand Up @@ -489,7 +489,7 @@ async def user() -> None:
[typing fixtures/typing-full.pyi]

[case testAsyncGeneratorAsend]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import AsyncGenerator

async def f() -> None:
Expand All @@ -510,7 +510,7 @@ async def h() -> None:
[typing fixtures/typing-full.pyi]

[case testAsyncGeneratorAthrow]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import AsyncGenerator

async def gen() -> AsyncGenerator[str, int]:
Expand All @@ -529,7 +529,7 @@ async def h() -> None:
[typing fixtures/typing-full.pyi]

[case testAsyncGeneratorNoSyncIteration]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import AsyncGenerator

async def gen() -> AsyncGenerator[int, None]:
Expand All @@ -547,7 +547,7 @@ def h() -> None:
main:9: error: "AsyncGenerator[int, None]" has no attribute "__iter__"; maybe "__aiter__"? (not iterable)

[case testAsyncGeneratorNoYieldFrom]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import AsyncGenerator

async def f() -> AsyncGenerator[int, None]:
Expand All @@ -560,7 +560,7 @@ async def gen() -> AsyncGenerator[int, None]:
[typing fixtures/typing-full.pyi]

[case testAsyncGeneratorNoReturnWithValue]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import AsyncGenerator

async def return_int() -> AsyncGenerator[int, None]:
Expand Down
10 changes: 5 additions & 5 deletions test-data/unit/check-class-namedtuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def f(a: Type[N]):
main:9: error: Too few arguments for "N"

[case testNewNamedTupleWithDefaults]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import List, NamedTuple, Optional

class X(NamedTuple):
Expand Down Expand Up @@ -431,7 +431,7 @@ UserDefined(1) # E: Argument 1 to "UserDefined" has incompatible type "int"; ex
[builtins fixtures/list.pyi]

[case testNewNamedTupleWithDefaultsStrictOptional]
# flags: --fast-parser --strict-optional --python-version 3.6
# flags: --strict-optional --python-version 3.6
from typing import List, NamedTuple, Optional

class HasNone(NamedTuple):
Expand All @@ -450,22 +450,22 @@ class CannotBeNone(NamedTuple):
[builtins fixtures/list.pyi]

[case testNewNamedTupleWrongType]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import NamedTuple

class X(NamedTuple):
x: int
y: int = 'not an int' # E: Incompatible types in assignment (expression has type "str", variable has type "int")

[case testNewNamedTupleErrorInDefault]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import NamedTuple

class X(NamedTuple):
x: int = 1 + '1' # E: Unsupported operand types for + ("int" and "str")

[case testNewNamedTupleInheritance]
# flags: --fast-parser --python-version 3.6
# flags: --python-version 3.6
from typing import NamedTuple

class X(NamedTuple):
Expand Down
64 changes: 0 additions & 64 deletions test-data/unit/check-flags.test
Original file line number Diff line number Diff line change
Expand Up @@ -446,70 +446,6 @@ main:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports"
from mod import x
[out]

[case testStrictBoolean]
# flags: --strict-boolean
if True:
pass
if 'test': # E: Condition must be a boolean
pass
elif 1: # E: Condition must be a boolean
pass

def f() -> bool:
return True

if f: # E: Condition must be a boolean
pass

if f():
pass

class A:
def __call__(self) -> bool:
return False

if A: # E: Condition must be a boolean
pass

if A(): # E: Condition must be a boolean
pass

if A()():
pass
[builtins fixtures/bool.pyi]

[case testStrictBooleanTernary]
# flags: --strict-boolean
x = 1 if 'test' else 2 # E: Condition must be a boolean
y = 1 if not 'test' else 2
[builtins fixtures/bool.pyi]

[case testStrictBooleanWhile]
# flags: --strict-boolean
while 5: # E: Condition must be a boolean
pass

while False:
pass
[builtins fixtures/bool.pyi]

[case testStrictBooleanComplexTypes]
# flags: --strict-boolean
from typing import Any, Type, Union

x = True # type: Any
y = True # type: Union[bool, int]
z = int # type: Type[int]

if x:
pass
if y: # E: Condition must be a boolean
pass
if z: # E: Condition must be a boolean
pass
[builtins fixtures/bool.pyi]


[case testPerFileIncompleteDefsBasic]
# flags: --config-file tmp/mypy.ini
import standard, incomplete
Expand Down