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

Bump typing_extensions dependency #15488

Merged
merged 3 commits into from
Jun 21, 2023

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jun 21, 2023

Mypy started using typing_extensions.Self which is only available in >=4.0.0.
https://github.com/python/typing_extensions/blob/main/CHANGELOG.md#release-401-november-30-2021

Fixes: #15487

setup.py Outdated Show resolved Hide resolved
@AlexWaygood
Copy link
Member

I checked for other imports using this script:

import ast
import itertools
import pathlib

names = set[str]()

class ImportFinder(ast.NodeVisitor):
    def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
        self.generic_visit(node)
        if node.module != "typing_extensions":
            return
        names.update({obj.name for obj in node.names})

    def visit_Attribute(self, node: ast.Attribute) -> None:
        self.generic_visit(node)
        match node:
            case ast.Attribute(ast.Name("typing_extensions"), attr):
                names.add(attr)
            case _:
                pass


for path in itertools.chain(
    pathlib.Path("mypy").rglob("*.py"),
    pathlib.Path("mypyc").rglob("*.py")
):
    ImportFinder().visit(ast.parse(path.read_text()))

print(names)

The is_typeddict one was the only other newish import from typing_extensions that the script surfaced.

Co-authored-by: Alex Waygood <[email protected]>
@@ -222,7 +222,7 @@ def run(self):
# When changing this, also update mypy-requirements.txt.
Copy link
Member

Choose a reason for hiding this comment

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

We should probably also update mypy-requirements.txt

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@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.

Thanks all!

@hauntsaninja hauntsaninja merged commit 8884518 into python:master Jun 21, 2023
@cdce8p cdce8p deleted the bump-typing-extensions branch June 21, 2023 20:02
hauntsaninja pushed a commit that referenced this pull request Jun 24, 2023
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.

mypy 1.4.0 is not compatible with typing-extensions 3.10 version
3 participants