Skip to content
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
8 changes: 1 addition & 7 deletions misc/dump-ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,14 @@ def main() -> None:
parser = argparse.ArgumentParser(
description="Parse source files and print the abstract syntax tree (AST)."
)
parser.add_argument("--py2", action="store_true", help="parse FILEs as Python 2")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is our internal tool, so we can remove this option, end users are not affected.

parser.add_argument("--quiet", action="store_true", help="do not print AST")
parser.add_argument("FILE", nargs="*", help="files to parse")
args = parser.parse_args()

if args.py2:
pyversion = defaults.PYTHON2_VERSION
else:
pyversion = defaults.PYTHON3_VERSION

status = 0
for fname in args.FILE:
try:
dump(fname, pyversion, args.quiet)
dump(fname, defaults.PYTHON3_VERSION, args.quiet)
except CompileError as e:
for msg in e.messages:
sys.stderr.write("%s\n" % msg)
Expand Down
3 changes: 0 additions & 3 deletions mypy/dmypy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,6 @@ def filter_out_missing_top_level_packages(
+ search_paths.package_path
+ search_paths.typeshed_path
)
paths += tuple(os.path.join(p, "@python2") for p in search_paths.typeshed_path)
for p in paths:
try:
entries = fscache.listdir(p)
Expand All @@ -1038,8 +1037,6 @@ def filter_out_missing_top_level_packages(
elif entry.endswith("-stubs"):
# Possible PEP 561 stub package
entry = entry[:-6]
if entry.endswith("-python2"):
entry = entry[:-8]
if entry in packages:
found.add(entry)
return found
12 changes: 2 additions & 10 deletions mypy/test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,6 @@ def testfile_pyversion(path: str) -> Tuple[int, int]:
return defaults.PYTHON3_VERSION


def testcase_pyversion(path: str, testcase_name: str) -> Tuple[int, int]:
if testcase_name.endswith("python2"):
raise ValueError(testcase_name)
return defaults.PYTHON2_VERSION
else:
return testfile_pyversion(path)


def normalize_error_messages(messages: List[str]) -> List[str]:
"""Translate an array of error messages to use / as path separator."""

Expand Down Expand Up @@ -384,9 +376,9 @@ def parse_options(
options.strict_optional = False
options.error_summary = False

# Allow custom python version to override testcase_pyversion.
# Allow custom python version to override testfile_pyversion.
if all(flag.split("=")[0] not in ["--python-version", "-2", "--py2"] for flag in flag_list):
options.python_version = testcase_pyversion(testcase.file, testcase.name)
options.python_version = testfile_pyversion(testcase.file)

if testcase.config.getoption("--mypy-verbose"):
options.verbosity = testcase.config.getoption("--mypy-verbose")
Expand Down
6 changes: 3 additions & 3 deletions mypy/test/testdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def test_filter_out_missing_top_level_packages(self) -> None:
self.make_file(td, "base/c.pyi")
self.make_file(td, "base/missing.txt")
self.make_file(td, "typeshed/d.pyi")
self.make_file(td, "typeshed/@python2/e")
self.make_file(td, "typeshed/@python2/e") # outdated
self.make_file(td, "pkg1/f-stubs")
self.make_file(td, "pkg2/g-python2-stubs")
self.make_file(td, "pkg2/g-python2-stubs") # outdated
self.make_file(td, "mpath/sub/long_name/")

def makepath(p: str) -> str:
Expand All @@ -128,7 +128,7 @@ def makepath(p: str) -> str:
res = filter_out_missing_top_level_packages(
{"a", "b", "c", "d", "e", "f", "g", "long_name", "ff", "missing"}, search, fscache
)
assert res == {"a", "b", "c", "d", "e", "f", "g", "long_name"}
assert res == {"a", "b", "c", "d", "f", "long_name"}

def make_file(self, base: str, path: str) -> None:
fullpath = os.path.join(base, path)
Expand Down
5 changes: 0 additions & 5 deletions test-data/unit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ First install any additional dependencies needed for testing:

python3 -m pip install -U -r test-requirements.txt

You must also have a Python 2.7 binary installed that can import the `typing`
module:

python2 -m pip install -U typing

The unit test suites are driven by the `pytest` framework. To run all mypy tests,
run `pytest` in the mypy repository:

Expand Down
8 changes: 4 additions & 4 deletions test-data/unit/check-enum.test
Original file line number Diff line number Diff line change
Expand Up @@ -565,15 +565,15 @@ def fn(x: F) -> None:
fn(b)
[out]

[case testFunctionalEnum_python2-skip]
[case testFunctionalEnum]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it does not hurt to keep this test.

# TODO: Needs to have enum34 stubs somehow
from enum import Enum
Eu = Enum(u'Eu', u'a b')
Eb = Enum(b'Eb', b'a b')
Eb = Enum(b'Eb', b'a b') # E: Enum() expects a string literal as the first argument
Gu = Enum(u'Gu', {u'a': 1})
Gb = Enum(b'Gb', {b'a': 1})
Gb = Enum(b'Gb', {b'a': 1}) # E: Enum() expects a string literal as the first argument
Hu = Enum(u'Hu', [u'a'])
Hb = Enum(b'Hb', [b'a'])
Hb = Enum(b'Hb', [b'a']) # E: Enum() expects a string literal as the first argument
Eu.a
Eb.a
Gu.a
Expand Down
3 changes: 2 additions & 1 deletion test-data/unit/check-selftype.test
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,10 @@ main:21: note: def do_x(cls) -> Good
# Friendlier error messages for common mistakes. See #2950
class A:
def f(x: int) -> None: ...
# def g(self: None) -> None: ... see in check-python2.test
def g(self: None) -> None: ...
[out]
main:3: error: Self argument missing for a non-static method (or an invalid type for self)
main:4: error: The erased type of self "None" is not a supertype of its class "__main__.A"

[case testUnionPropertyField]
from typing import Union
Expand Down