Use python.typing.org for typing documentation links (#17323)

## Summary

There is a new official URL for the typing documentation:
https://typing.python.org/

Change all https://typing.readthedocs.io/ links to use the new sub
domain, which is slightly shorter and looks more official.

## Test Plan

Tested to see if each and every new URL is accessible. I noticed that
some links go to https://typing.python.org/en/latest/source/stubs.html
which seems to be outdated, but that is a separate issue. The same page
shows up for the old URL.
This commit is contained in:
David Peter
2025-04-09 20:38:20 +02:00
committed by GitHub
parent 144484d46c
commit 5fef4d4572
37 changed files with 57 additions and 57 deletions

View File

@@ -2,7 +2,7 @@
References:
- <https://typing.readthedocs.io/en/latest/spec/callables.html#callable>
- <https://typing.python.org/en/latest/spec/callables.html#callable>
Note that `typing.Callable` is deprecated at runtime, in favour of `collections.abc.Callable` (see:
<https://docs.python.org/3/library/typing.html#deprecated-aliases>). However, removal of
@@ -299,4 +299,4 @@ def _(c: Callable[[int], int]):
reveal_type(c.__call__) # revealed: Unknown
```
[gradual form]: https://typing.readthedocs.io/en/latest/spec/glossary.html#term-gradual-form
[gradual form]: https://typing.python.org/en/latest/spec/glossary.html#term-gradual-form

View File

@@ -2,7 +2,7 @@
In order to support common use cases, an annotation of `float` actually means `int | float`, and an
annotation of `complex` actually means `int | float | complex`. See
[the specification](https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex)
[the specification](https://typing.python.org/en/latest/spec/special-types.html#special-cases-for-float-and-complex)
## float

View File

@@ -1,6 +1,6 @@
# Literal
<https://typing.readthedocs.io/en/latest/spec/literal.html#literals>
<https://typing.python.org/en/latest/spec/literal.html#literals>
## Parameterization

View File

@@ -147,4 +147,4 @@ def f():
reveal_type(x) # revealed: LiteralString
```
[1]: https://typing.readthedocs.io/en/latest/spec/literal.html#literalstring
[1]: https://typing.python.org/en/latest/spec/literal.html#literalstring

View File

@@ -1800,5 +1800,5 @@ Some of the tests in the *Class and instance variables* section draw inspiration
[descriptor protocol tests]: descriptor_protocol.md
[pyright's documentation]: https://microsoft.github.io/pyright/#/type-concepts-advanced?id=class-and-instance-variables
[typing spec on `classvar`]: https://typing.readthedocs.io/en/latest/spec/class-compat.html#classvar
[typing spec on `classvar`]: https://typing.python.org/en/latest/spec/class-compat.html#classvar
[`typing.classvar`]: https://docs.python.org/3/library/typing.html#typing.ClassVar

View File

@@ -122,4 +122,4 @@ class Wrapper:
reveal_type(Wrapper.value) # revealed: Unknown | None
```
[gradual guarantee]: https://typing.readthedocs.io/en/latest/spec/concepts.html#the-gradual-guarantee
[gradual guarantee]: https://typing.python.org/en/latest/spec/concepts.html#the-gradual-guarantee

View File

@@ -69,4 +69,4 @@ from typing import TypeVar
T = TypeVar("T", int)
```
[generics]: https://typing.readthedocs.io/en/latest/spec/generics.html
[generics]: https://typing.python.org/en/latest/spec/generics.html

View File

@@ -299,4 +299,4 @@ class C[T]:
ok2: Inner[T]
```
[scoping]: https://typing.readthedocs.io/en/latest/spec/generics.html#scoping-rules-for-type-variables
[scoping]: https://typing.python.org/en/latest/spec/generics.html#scoping-rules-for-type-variables

View File

@@ -4,7 +4,7 @@ This document describes the conventions for importing symbols.
Reference:
- <https://typing.readthedocs.io/en/latest/spec/distributing.html#import-conventions>
- <https://typing.python.org/en/latest/spec/distributing.html#import-conventions>
## Builtins scope

View File

@@ -3,7 +3,7 @@
> If a type checker supports the `no_type_check` decorator for functions, it should suppress all
> type errors for the def statement and its body including any nested functions or classes. It
> should also ignore all parameter and return type annotations and treat the function as if it were
> unannotated. [source](https://typing.readthedocs.io/en/latest/spec/directives.html#no-type-check)
> unannotated. [source](https://typing.python.org/en/latest/spec/directives.html#no-type-check)
## Error in the function body
@@ -95,7 +95,7 @@ def test() -> Undefined:
Red Knot does not support decorating classes with `no_type_check`. The behaviour of `no_type_check`
when applied to classes is
[not specified currently](https://typing.readthedocs.io/en/latest/spec/directives.html#no-type-check),
[not specified currently](https://typing.python.org/en/latest/spec/directives.html#no-type-check),
and is not supported by Pyright or mypy.
A future improvement might be to emit a diagnostic if a `no_type_check` annotation is applied to a

View File

@@ -504,4 +504,4 @@ c: Callable[[Any], str] = f
c: Callable[[Any], str] = g
```
[typing documentation]: https://typing.readthedocs.io/en/latest/spec/concepts.html#the-assignable-to-or-consistent-subtyping-relation
[typing documentation]: https://typing.python.org/en/latest/spec/concepts.html#the-assignable-to-or-consistent-subtyping-relation

View File

@@ -254,4 +254,4 @@ from knot_extensions import is_equivalent_to, static_assert
static_assert(is_equivalent_to(int | Callable[[int | str], None], Callable[[str | int], None] | int))
```
[the equivalence relation]: https://typing.readthedocs.io/en/latest/spec/glossary.html#term-equivalent
[the equivalence relation]: https://typing.python.org/en/latest/spec/glossary.html#term-equivalent

View File

@@ -157,4 +157,4 @@ def f6(a, /): ...
static_assert(not is_gradual_equivalent_to(CallableTypeOf[f1], CallableTypeOf[f6]))
```
[materializations]: https://typing.readthedocs.io/en/latest/spec/glossary.html#term-materialize
[materializations]: https://typing.python.org/en/latest/spec/glossary.html#term-materialize

View File

@@ -1148,5 +1148,5 @@ static_assert(not is_subtype_of(TypeOf[A.g], Callable[[], int]))
static_assert(is_subtype_of(TypeOf[A.f], Callable[[A, int], int]))
```
[special case for float and complex]: https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex
[typing documentation]: https://typing.readthedocs.io/en/latest/spec/concepts.html#subtype-supertype-and-type-equivalence
[special case for float and complex]: https://typing.python.org/en/latest/spec/special-types.html#special-cases-for-float-and-complex
[typing documentation]: https://typing.python.org/en/latest/spec/concepts.html#subtype-supertype-and-type-equivalence

View File

@@ -168,7 +168,7 @@ impl SearchPaths {
///
/// This method also implements the typing spec's [module resolution order].
///
/// [module resolution order]: https://typing.readthedocs.io/en/latest/spec/distributing.html#import-resolution-ordering
/// [module resolution order]: https://typing.python.org/en/latest/spec/distributing.html#import-resolution-ordering
pub(crate) fn from_settings(
db: &dyn Db,
settings: &SearchPathSettings,

View File

@@ -535,7 +535,7 @@ impl<'a> SuppressionsBuilder<'a> {
// > imports, or other executable code, silences all errors in the file.
// > Blank lines and other comments, such as shebang lines and coding cookies,
// > may precede the # type: ignore comment.
// > https://typing.readthedocs.io/en/latest/spec/directives.html#type-ignore-comments
// > https://typing.python.org/en/latest/spec/directives.html#type-ignore-comments
let is_file_suppression = comment.kind.is_type_ignore() && !self.seen_non_trivia_token;
let suppressed_range = if is_file_suppression {

View File

@@ -766,7 +766,7 @@ impl<'db> Type<'db> {
///
/// This method returns `false` if either `self` or `other` is not fully static.
///
/// [subtype of]: https://typing.readthedocs.io/en/latest/spec/concepts.html#subtype-supertype-and-type-equivalence
/// [subtype of]: https://typing.python.org/en/latest/spec/concepts.html#subtype-supertype-and-type-equivalence
pub(crate) fn is_subtype_of(self, db: &'db dyn Db, target: Type<'db>) -> bool {
// Two equivalent types are always subtypes of each other.
//
@@ -1056,7 +1056,7 @@ impl<'db> Type<'db> {
/// Return true if this type is [assignable to] type `target`.
///
/// [assignable to]: https://typing.readthedocs.io/en/latest/spec/concepts.html#the-assignable-to-or-consistent-subtyping-relation
/// [assignable to]: https://typing.python.org/en/latest/spec/concepts.html#the-assignable-to-or-consistent-subtyping-relation
pub(crate) fn is_assignable_to(self, db: &'db dyn Db, target: Type<'db>) -> bool {
if self.is_gradual_equivalent_to(db, target) {
return true;
@@ -1274,7 +1274,7 @@ impl<'db> Type<'db> {
///
/// This method returns `false` if either `self` or `other` is not fully static.
///
/// [equivalent to]: https://typing.readthedocs.io/en/latest/spec/glossary.html#term-equivalent
/// [equivalent to]: https://typing.python.org/en/latest/spec/glossary.html#term-equivalent
pub(crate) fn is_equivalent_to(self, db: &'db dyn Db, other: Type<'db>) -> bool {
// TODO equivalent but not identical types: TypedDicts, Protocols, type aliases, etc.
@@ -1318,7 +1318,7 @@ impl<'db> Type<'db> {
///
/// This powers the `assert_type()` directive.
///
/// [Summary of type relations]: https://typing.readthedocs.io/en/latest/spec/concepts.html#summary-of-type-relations
/// [Summary of type relations]: https://typing.python.org/en/latest/spec/concepts.html#summary-of-type-relations
pub(crate) fn is_gradual_equivalent_to(self, db: &'db dyn Db, other: Type<'db>) -> bool {
if self == other {
return true;
@@ -3857,7 +3857,7 @@ impl<'db> Type<'db> {
) -> Result<Type<'db>, InvalidTypeExpressionError<'db>> {
match self {
// Special cases for `float` and `complex`
// https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex
// https://typing.python.org/en/latest/spec/special-types.html#special-cases-for-float-and-complex
Type::ClassLiteral(class) => {
let ty = match class.known(db) {
Some(KnownClass::Any) => Type::any(),
@@ -5462,7 +5462,7 @@ pub enum KnownFunction {
/// `typing(_extensions).final`
Final,
/// [`typing(_extensions).no_type_check`](https://typing.readthedocs.io/en/latest/spec/directives.html#no-type-check)
/// [`typing(_extensions).no_type_check`](https://typing.python.org/en/latest/spec/directives.html#no-type-check)
NoTypeCheck,
/// `typing(_extensions).assert_type`

View File

@@ -6223,9 +6223,9 @@ impl<'db> TypeInferenceBuilder<'db> {
&mut self,
annotation: &ast::Expr,
) -> TypeAndQualifiers<'db> {
// https://typing.readthedocs.io/en/latest/spec/annotations.html#grammar-token-expression-grammar-annotation_expression
// https://typing.python.org/en/latest/spec/annotations.html#grammar-token-expression-grammar-annotation_expression
let annotation_ty = match annotation {
// String annotations: https://typing.readthedocs.io/en/latest/spec/annotations.html#string-annotations
// String annotations: https://typing.python.org/en/latest/spec/annotations.html#string-annotations
ast::Expr::StringLiteral(string) => self.infer_string_annotation_expression(string),
// Annotation expressions also get special handling for `*args` and `**kwargs`.
@@ -6420,7 +6420,7 @@ impl<'db> TypeInferenceBuilder<'db> {
/// Infer the type of a type expression without storing the result.
fn infer_type_expression_no_store(&mut self, expression: &ast::Expr) -> Type<'db> {
// https://typing.readthedocs.io/en/latest/spec/annotations.html#grammar-token-expression-grammar-type_expression
// https://typing.python.org/en/latest/spec/annotations.html#grammar-token-expression-grammar-type_expression
match expression {
ast::Expr::Name(name) => match name.ctx {
ast::ExprContext::Load => self
@@ -6446,7 +6446,7 @@ impl<'db> TypeInferenceBuilder<'db> {
ast::Expr::NoneLiteral(_literal) => Type::none(self.db()),
// https://typing.readthedocs.io/en/latest/spec/annotations.html#string-annotations
// https://typing.python.org/en/latest/spec/annotations.html#string-annotations
ast::Expr::StringLiteral(string) => self.infer_string_type_expression(string),
ast::Expr::Subscript(subscript) => {