Skip to content

Bump typing_extensions dependency#15488

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

Bump typing_extensions dependency#15488
hauntsaninja merged 3 commits intopython:masterfrom
cdce8p:bump-typing-extensions

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

@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 <Alex.Waygood@Gmail.com>
@@ -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
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

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