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

No longer support checking Python 2 #13135

Merged
merged 25 commits into from
Jul 26, 2022
Merged

Conversation

hauntsaninja
Copy link
Collaborator

Linking #12237

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@hauntsaninja hauntsaninja marked this pull request as ready for review July 19, 2022 03:14
@@ -287,6 +287,7 @@ def num_skipped_suffix_lines(a1: List[str], a2: List[str]) -> int:

def testfile_pyversion(path: str) -> Tuple[int, int]:
if path.endswith('python2.test'):
raise ValueError(path)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just remove this case?

@@ -296,6 +297,7 @@ def testfile_pyversion(path: str) -> Tuple[int, int]:

def testcase_pyversion(path: str, testcase_name: str) -> Tuple[int, int]:
if testcase_name.endswith('python2'):
raise ValueError(testcase_name)
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@@ -30,6 +30,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None:
dump_all = '# __dump_all__' in src
options = parse_options(src, testcase, incremental_step=1)
if testcase.name.endswith('python2'):
raise ValueError(testcase.name)
Copy link
Member

Choose a reason for hiding this comment

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

And again

@@ -32,6 +32,7 @@ def test_parser(testcase: DataDrivenTestCase) -> None:
options = Options()

if testcase.file.endswith('python2.test'):
raise ValueError(testcase.name)
Copy link
Member

Choose a reason for hiding this comment

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

same

@@ -61,13 +57,7 @@ def test_python_evaluation(testcase: DataDrivenTestCase, cache_dir: str) -> None
]
py2 = testcase.name.lower().endswith('python2')
Copy link
Member

Choose a reason for hiding this comment

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

again

Copy link
Collaborator Author

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

I left those in semi-intentionally, since it proves this removes all tests, before it removes the test scaffolding. But I can remove them

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

There are still lots of python2 specific logic pieces in checker.py and checkmember.py (probably somewhere else), but this is a great start!

mypy/main.py Outdated Show resolved Hide resolved
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Love to see so many negative lines!

Looks good, but I found a few test cases that might still be relevant after Python 2 support has been dropped. Can you double check them? Feel free to merge afterwards.

@@ -130,30 +130,6 @@ two/mod/__init__.py: note: See https://mypy.readthedocs.io/en/stable/running_myp
two/mod/__init__.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
== Return code: 2

[case testFlagsFile]
# cmd: mypy @flagsfile
Copy link
Collaborator

Choose a reason for hiding this comment

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

There doesn't seem to be any other test case that uses @flagsfile, so this test case should not be deleted. We should just change it to use some other flags.

except ZeroDivisionError, err:
print err

[case testConfigFile]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to above, this doesn't look Python 2 specific as such, but tests using mypy.ini. Please update the test case to use some other config file option.

@@ -166,18 +142,6 @@ def f() -> None:
main.py: note: In function "f":
main.py:2: error: Unsupported operand types for + ("int" and "str")

[case testAltConfigFile]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to above -- keep this test case but use some other config file option.

@@ -2158,23 +2158,6 @@ main.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mis
main.py:2: error: Incompatible types in assignment (expression has type "int", variable has type "str")
==

[case testMissingStubAdded2]
# flags: --follow-imports=skip --py2
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test case might still be relevant. I think that it's better to just drop the --py2 flag but keep the test case.

@hauntsaninja
Copy link
Collaborator Author

Thanks, brought back the test cases you mentioned. I was running into some weird issues with testFlagsFile that I couldn't quite figure out — mypy's behaviour outside of the test suite is correct, so I skipped it for now. If I'm not able to figure it out soon, I'll file an issue and fix asynchronously.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@ilevkivskyi
Copy link
Member

I think we should go ahead with this and fix testFlagsFile later separately. @hauntsaninja please don't forget to make a follow-up PR.

@ilevkivskyi ilevkivskyi merged commit 5718dff into python:master Jul 26, 2022
@hauntsaninja hauntsaninja mentioned this pull request Jul 26, 2022
@hauntsaninja hauntsaninja deleted the py2-2022 branch July 26, 2022 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants