Skip to content

Bump typing_extensions dependency - #15488

Merged
hauntsaninja merged 3 commits into
python:masterfrom
cdce8p:bump-typing-extensions
Jun 21, 2023
Merged

hauntsaninja merged 3 commits into
python:masterfrom
cdce8p:bump-typing-extensions

Conversation

@cdce8p

@cdce8p cdce8p commented Jun 21, 2023

Copy link
Copy Markdown
Collaborator

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

Comment thread setup.py Resolved
@AlexWaygood

Copy link
Copy Markdown
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 <Alex.Waygood@Gmail.com>
Comment thread setup.py
@@ -222,7 +222,7 @@ def run(self):
# When changing this, also update mypy-requirements.txt.

Copy link
Copy Markdown
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

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor

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

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

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
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants