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

[red-knot] Import LiteralString/Never from typing_extensions #14817

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Dec 6, 2024

Summary

typing.Never and typing.LiteralString are only conditionally exported from typing for Python versions 3.11 and later. We run the Markdown tests with the default Python version of 3.9, so here we change the import to typing_extensions instead, and add a new test to make sure we'll continue to understand the typing-version of these symbols for newer versions.

This didn't cause problems so far, as we don't understand sys.version_info branches yet.

Test Plan

New Markdown tests to make sure this will continue to work in the future.

`typing.Never` and `typing.LiteralString` are only conditionally
exported from `typing` for Python versions 3.11 and later. We run the
Markdown tests with the default Python version of 3.9, so here we change
the import to `typing_extensions` instead, and add a new test to make
sure we'll continue to understand the `typing`-version of these symbols
for newer versions.

This didn't cause problems so far, as we don't understand
`sys.version_info` branches yet.
@sharkdp sharkdp added the red-knot Multi-file analysis & type inference label Dec 6, 2024
@@ -57,6 +57,8 @@ class C(LiteralString): ... # error: [invalid-base]
### Common operations

```py
from typing_extensions import LiteralString
Copy link
Contributor Author

@sharkdp sharkdp Dec 6, 2024

Choose a reason for hiding this comment

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

These imports were simply missing. This didn't cause problems so far because of #14099 (thanks @AlexWaygood)

Copy link
Contributor

github-actions bot commented Dec 6, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@sharkdp sharkdp merged commit 6b9f3d7 into main Dec 6, 2024
21 checks passed
@sharkdp sharkdp deleted the david/typing_extensions-imports branch December 6, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants