Skip to content

Replace deprecated typing.List and friends - #16527

Open
jonathandung wants to merge 8 commits into
python:mainfrom
jonathandung:patch-6
Open

jonathandung wants to merge 8 commits into
python:mainfrom
jonathandung:patch-6

Conversation

@jonathandung

@jonathandung jonathandung commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Since Python 3.10 is the lowest supported Python version, this pull request replaces some of the instances of typing.List, typing.Tuple and typing.Union I found across the repository with list, tuple and | respectively. This removal mainly applies to tests.

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

@jonathandung
jonathandung marked this pull request as draft October 14, 2026 03:27
@jonathandung
jonathandung marked this pull request as ready for review October 14, 2026 14:34
@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

def is_dataclass_any(arg: Any) -> None:
if dc.is_dataclass(arg):
assert_type(arg, Union["DataclassInstance", Type["DataclassInstance"]])
assert_type(arg, "DataclassInstance" | type["DataclassInstance"])

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.

Isn't this a runtime error (can't do | with a string)? We should avoid using that in tests because a reasonable type checker could error on it.

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.

ty actually does catch that, i believe, at least in some situations

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just noticed the file already had from __future__ import annotations at the beginning. I believe the quotes can be removed (correct me if I'm wrong).

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.

That doesn't do anything here because this is not an annotation.

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.

Though maybe the quotes can be removed anyway here, not sure why they would be needed.

This branch has not been deployed

No deployments
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.

3 participants