Skip to content

Commit

Permalink
Avoid using typing.Self in stub files pre-Python 3.11 (#14230)
Browse files Browse the repository at this point in the history
## Summary

See:
#14217 (comment).

This means we're recommending `typing_extensions` in non-stubs pre-3.11,
which may not be a valid project dependency, but that's a separate issue
(#9761).
  • Loading branch information
charliermarsh authored Nov 9, 2024
1 parent ce3af27 commit 1279c20
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn add_diagnostic(
/// Return an [`Edit`] that imports `typing.Self` from `typing` or `typing_extensions`.
fn import_self(checker: &Checker, range: TextRange) -> Option<Edit> {
let target_version = checker.settings.target_version.as_tuple();
let source_module = if checker.source_type.is_stub() || target_version >= (3, 11) {
let source_module = if target_version >= (3, 11) {
"typing"
} else {
"typing_extensions"
Expand Down

0 comments on commit 1279c20

Please sign in to comment.