diff --git a/crates/red_knot_python_semantic/resources/mdtest/annotations/callable.md b/crates/red_knot_python_semantic/resources/mdtest/annotations/callable.md index cf411d802e..e17cb1cbf3 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/annotations/callable.md +++ b/crates/red_knot_python_semantic/resources/mdtest/annotations/callable.md @@ -2,7 +2,7 @@ References: -- +- Note that `typing.Callable` is deprecated at runtime, in favour of `collections.abc.Callable` (see: ). 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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/annotations/int_float_complex.md b/crates/red_knot_python_semantic/resources/mdtest/annotations/int_float_complex.md index a3b6a7bf00..e32bb5d108 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/annotations/int_float_complex.md +++ b/crates/red_knot_python_semantic/resources/mdtest/annotations/int_float_complex.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/annotations/literal.md b/crates/red_knot_python_semantic/resources/mdtest/annotations/literal.md index 97cd141494..75c311800b 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/annotations/literal.md +++ b/crates/red_knot_python_semantic/resources/mdtest/annotations/literal.md @@ -1,6 +1,6 @@ # Literal - + ## Parameterization diff --git a/crates/red_knot_python_semantic/resources/mdtest/annotations/literal_string.md b/crates/red_knot_python_semantic/resources/mdtest/annotations/literal_string.md index 87cf536333..45dff62b80 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/annotations/literal_string.md +++ b/crates/red_knot_python_semantic/resources/mdtest/annotations/literal_string.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/attributes.md b/crates/red_knot_python_semantic/resources/mdtest/attributes.md index 7ca665a983..62bd3154d9 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/attributes.md +++ b/crates/red_knot_python_semantic/resources/mdtest/attributes.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/doc/public_type_undeclared_symbols.md b/crates/red_knot_python_semantic/resources/mdtest/doc/public_type_undeclared_symbols.md index c2f5896199..20216871fe 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/doc/public_type_undeclared_symbols.md +++ b/crates/red_knot_python_semantic/resources/mdtest/doc/public_type_undeclared_symbols.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/generics/legacy.md b/crates/red_knot_python_semantic/resources/mdtest/generics/legacy.md index a62141ea78..6aea25ed82 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/generics/legacy.md +++ b/crates/red_knot_python_semantic/resources/mdtest/generics/legacy.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/generics/scoping.md b/crates/red_knot_python_semantic/resources/mdtest/generics/scoping.md index 2884b8d1b1..2a8d75b16e 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/generics/scoping.md +++ b/crates/red_knot_python_semantic/resources/mdtest/generics/scoping.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/import/conventions.md b/crates/red_knot_python_semantic/resources/mdtest/import/conventions.md index 5e58b8a6f1..bb7cf890b0 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/import/conventions.md +++ b/crates/red_knot_python_semantic/resources/mdtest/import/conventions.md @@ -4,7 +4,7 @@ This document describes the conventions for importing symbols. Reference: -- +- ## Builtins scope diff --git a/crates/red_knot_python_semantic/resources/mdtest/suppressions/no_type_check.md b/crates/red_knot_python_semantic/resources/mdtest/suppressions/no_type_check.md index b9fd685c45..21f2cb9dc4 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/suppressions/no_type_check.md +++ b/crates/red_knot_python_semantic/resources/mdtest/suppressions/no_type_check.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md b/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md index cdbabc9d80..33d730c189 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md +++ b/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_equivalent_to.md b/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_equivalent_to.md index 031de910a0..39aa18fc43 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_equivalent_to.md +++ b/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_equivalent_to.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_gradual_equivalent_to.md b/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_gradual_equivalent_to.md index 7bc43b69e7..43062b1802 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_gradual_equivalent_to.md +++ b/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_gradual_equivalent_to.md @@ -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 diff --git a/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_subtype_of.md b/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_subtype_of.md index 307c7ec527..7763b3b1a6 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_subtype_of.md +++ b/crates/red_knot_python_semantic/resources/mdtest/type_properties/is_subtype_of.md @@ -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 diff --git a/crates/red_knot_python_semantic/src/module_resolver/resolver.rs b/crates/red_knot_python_semantic/src/module_resolver/resolver.rs index a3ae6d805b..37fb4d1d40 100644 --- a/crates/red_knot_python_semantic/src/module_resolver/resolver.rs +++ b/crates/red_knot_python_semantic/src/module_resolver/resolver.rs @@ -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, diff --git a/crates/red_knot_python_semantic/src/suppression.rs b/crates/red_knot_python_semantic/src/suppression.rs index e3ac813226..ebfc62afd8 100644 --- a/crates/red_knot_python_semantic/src/suppression.rs +++ b/crates/red_knot_python_semantic/src/suppression.rs @@ -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 { diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index 41657e3bb8..5801f7eb6d 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -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, 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` diff --git a/crates/red_knot_python_semantic/src/types/infer.rs b/crates/red_knot_python_semantic/src/types/infer.rs index bee37ffefa..45f673e0fb 100644 --- a/crates/red_knot_python_semantic/src/types/infer.rs +++ b/crates/red_knot_python_semantic/src/types/infer.rs @@ -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) => { diff --git a/crates/red_knot_vendored/vendor/typeshed/README.md b/crates/red_knot_vendored/vendor/typeshed/README.md index b52ecf3a5d..303ba1a0b6 100644 --- a/crates/red_knot_vendored/vendor/typeshed/README.md +++ b/crates/red_knot_vendored/vendor/typeshed/README.md @@ -19,7 +19,7 @@ it before submitting pull requests; do not report issues with annotations to the project the stubs are for, but instead report them here to typeshed.** Further documentation on stub files, typeshed, and Python's typing system in -general, can also be found at https://typing.readthedocs.io/en/latest/. +general, can also be found at https://typing.python.org/en/latest/. Typeshed supports Python versions 3.9 to 3.13. diff --git a/crates/ruff/tests/snapshots/integration_test__rule_f401.snap b/crates/ruff/tests/snapshots/integration_test__rule_f401.snap index a767348175..3e9270c33e 100644 --- a/crates/ruff/tests/snapshots/integration_test__rule_f401.snap +++ b/crates/ruff/tests/snapshots/integration_test__rule_f401.snap @@ -91,6 +91,6 @@ else: ## References - [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement) - [Python documentation: `importlib.util.find_spec`](https://docs.python.org/3/library/importlib.html#importlib.util.find_spec) -- [Typing documentation: interface conventions](https://typing.readthedocs.io/en/latest/source/libraries.html#library-interface-public-and-private-symbols) +- [Typing documentation: interface conventions](https://typing.python.org/en/latest/source/libraries.html#library-interface-public-and-private-symbols) ----- stderr ----- diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__sarif__tests__results.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__sarif__tests__results.snap index 327ab346a3..373c7aa2ae 100644 --- a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__sarif__tests__results.snap +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__sarif__tests__results.snap @@ -81,7 +81,7 @@ expression: value "rules": [ { "fullDescription": { - "text": "## What it does\nChecks for unused imports.\n\n## Why is this bad?\nUnused imports add a performance overhead at runtime, and risk creating\nimport cycles. They also increase the cognitive load of reading the code.\n\nIf an import statement is used to check for the availability or existence\nof a module, consider using `importlib.util.find_spec` instead.\n\nIf an import statement is used to re-export a symbol as part of a module's\npublic interface, consider using a \"redundant\" import alias, which\ninstructs Ruff (and other tools) to respect the re-export, and avoid\nmarking it as unused, as in:\n\n```python\nfrom module import member as member\n```\n\nAlternatively, you can use `__all__` to declare a symbol as part of the module's\ninterface, as in:\n\n```python\n# __init__.py\nimport some_module\n\n__all__ = [\"some_module\"]\n```\n\n## Fix safety\n\nFixes to remove unused imports are safe, except in `__init__.py` files.\n\nApplying fixes to `__init__.py` files is currently in preview. The fix offered depends on the\ntype of the unused import. Ruff will suggest a safe fix to export first-party imports with\neither a redundant alias or, if already present in the file, an `__all__` entry. If multiple\n`__all__` declarations are present, Ruff will not offer a fix. Ruff will suggest an unsafe fix\nto remove third-party and standard library imports -- the fix is unsafe because the module's\ninterface changes.\n\n## Example\n\n```python\nimport numpy as np # unused import\n\n\ndef area(radius):\n return 3.14 * radius**2\n```\n\nUse instead:\n\n```python\ndef area(radius):\n return 3.14 * radius**2\n```\n\nTo check the availability of a module, use `importlib.util.find_spec`:\n\n```python\nfrom importlib.util import find_spec\n\nif find_spec(\"numpy\") is not None:\n print(\"numpy is installed\")\nelse:\n print(\"numpy is not installed\")\n```\n\n## Options\n- `lint.ignore-init-module-imports`\n- `lint.pyflakes.allowed-unused-imports`\n\n## References\n- [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement)\n- [Python documentation: `importlib.util.find_spec`](https://docs.python.org/3/library/importlib.html#importlib.util.find_spec)\n- [Typing documentation: interface conventions](https://typing.readthedocs.io/en/latest/source/libraries.html#library-interface-public-and-private-symbols)\n" + "text": "## What it does\nChecks for unused imports.\n\n## Why is this bad?\nUnused imports add a performance overhead at runtime, and risk creating\nimport cycles. They also increase the cognitive load of reading the code.\n\nIf an import statement is used to check for the availability or existence\nof a module, consider using `importlib.util.find_spec` instead.\n\nIf an import statement is used to re-export a symbol as part of a module's\npublic interface, consider using a \"redundant\" import alias, which\ninstructs Ruff (and other tools) to respect the re-export, and avoid\nmarking it as unused, as in:\n\n```python\nfrom module import member as member\n```\n\nAlternatively, you can use `__all__` to declare a symbol as part of the module's\ninterface, as in:\n\n```python\n# __init__.py\nimport some_module\n\n__all__ = [\"some_module\"]\n```\n\n## Fix safety\n\nFixes to remove unused imports are safe, except in `__init__.py` files.\n\nApplying fixes to `__init__.py` files is currently in preview. The fix offered depends on the\ntype of the unused import. Ruff will suggest a safe fix to export first-party imports with\neither a redundant alias or, if already present in the file, an `__all__` entry. If multiple\n`__all__` declarations are present, Ruff will not offer a fix. Ruff will suggest an unsafe fix\nto remove third-party and standard library imports -- the fix is unsafe because the module's\ninterface changes.\n\n## Example\n\n```python\nimport numpy as np # unused import\n\n\ndef area(radius):\n return 3.14 * radius**2\n```\n\nUse instead:\n\n```python\ndef area(radius):\n return 3.14 * radius**2\n```\n\nTo check the availability of a module, use `importlib.util.find_spec`:\n\n```python\nfrom importlib.util import find_spec\n\nif find_spec(\"numpy\") is not None:\n print(\"numpy is installed\")\nelse:\n print(\"numpy is not installed\")\n```\n\n## Options\n- `lint.ignore-init-module-imports`\n- `lint.pyflakes.allowed-unused-imports`\n\n## References\n- [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement)\n- [Python documentation: `importlib.util.find_spec`](https://docs.python.org/3/library/importlib.html#importlib.util.find_spec)\n- [Typing documentation: interface conventions](https://typing.python.org/en/latest/source/libraries.html#library-interface-public-and-private-symbols)\n" }, "help": { "text": "`{name}` imported but unused; consider using `importlib.util.find_spec` to test for availability" diff --git a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs index 56942616e7..fe3f2da497 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs +++ b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs @@ -480,7 +480,7 @@ impl Violation for MissingReturnTypeClassMethod { /// ``` /// /// ## References -/// - [Typing spec: `Any`](https://typing.readthedocs.io/en/latest/spec/special-types.html#any) +/// - [Typing spec: `Any`](https://typing.python.org/en/latest/spec/special-types.html#any) /// - [Python documentation: `typing.Any`](https://docs.python.org/3/library/typing.html#typing.Any) /// - [Mypy documentation: The Any type](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#the-any-type) #[derive(ViolationMetadata)] diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs index 980601e5d9..f432eae1f8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs @@ -30,7 +30,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## References -/// - [Typing documentation: Version and platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks) +/// - [Typing documentation: Version and platform checking](https://typing.python.org/en/latest/spec/directives.html#version-and-platform-checks) #[derive(ViolationMetadata)] pub(crate) struct ComplexIfStatementInStub; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/future_annotations_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/future_annotations_in_stub.rs index 397326755e..8949ff40ad 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/future_annotations_in_stub.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/future_annotations_in_stub.rs @@ -16,7 +16,7 @@ use crate::{checkers::ast::Checker, fix}; /// statement has no effect and should be omitted. /// /// ## References -/// - [Static Typing with Python: Type Stubs](https://typing.readthedocs.io/en/latest/source/stubs.html) +/// - [Static Typing with Python: Type Stubs](https://typing.python.org/en/latest/source/stubs.html) #[derive(ViolationMetadata)] pub(crate) struct FutureAnnotationsInStub; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/non_empty_stub_body.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/non_empty_stub_body.rs index f853baa539..b99413d599 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/non_empty_stub_body.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/non_empty_stub_body.rs @@ -26,7 +26,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## References -/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.readthedocs.io/en/latest/guides/writing_stubs.html) +/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.python.org/en/latest/guides/writing_stubs.html) #[derive(ViolationMetadata)] pub(crate) struct NonEmptyStubBody; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs index 27782c4342..f530b70259 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs @@ -23,7 +23,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## References -/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.readthedocs.io/en/latest/guides/writing_stubs.html) +/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.python.org/en/latest/guides/writing_stubs.html) #[derive(ViolationMetadata)] pub(crate) struct PassStatementStubBody; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs index 44059eb02c..8b8390c20c 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs @@ -27,7 +27,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## References -/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.readthedocs.io/en/latest/guides/writing_stubs.html) +/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.python.org/en/latest/guides/writing_stubs.html) #[derive(ViolationMetadata)] pub(crate) struct QuotedAnnotationInStub; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs index 9432521da6..8fa05574a0 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs @@ -46,7 +46,7 @@ use crate::{checkers::ast::Checker, importer::ImportRequest}; /// is 3.9 or below. /// /// ## References -/// - [Typing documentation: Legal parameters for `Literal` at type check time](https://typing.readthedocs.io/en/latest/spec/literal.html#legal-parameters-for-literal-at-type-check-time) +/// - [Typing documentation: Legal parameters for `Literal` at type check time](https://typing.python.org/en/latest/spec/literal.html#legal-parameters-for-literal-at-type-check-time) #[derive(ViolationMetadata)] pub(crate) struct RedundantNoneLiteral { union_kind: UnionKind, diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs index 6164bfa87b..494203d461 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs @@ -54,7 +54,7 @@ use crate::{checkers::ast::Checker, importer::ImportRequest}; /// - [Python documentation: The numeric tower](https://docs.python.org/3/library/numbers.html#the-numeric-tower) /// - [PEP 484: The numeric tower](https://peps.python.org/pep-0484/#the-numeric-tower) /// -/// [typing specification]: https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex +/// [typing specification]: https://typing.python.org/en/latest/spec/special-types.html#special-cases-for-float-and-complex #[derive(ViolationMetadata)] pub(crate) struct RedundantNumericUnion { redundancy: Redundancy, diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_platform.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_platform.rs index 22446ac78c..c5f2dafd9d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_platform.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_platform.rs @@ -40,7 +40,7 @@ use crate::registry::Rule; /// ``` /// /// ## References -/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks) +/// - [Typing documentation: Version and Platform checking](https://typing.python.org/en/latest/spec/directives.html#version-and-platform-checks) #[derive(ViolationMetadata)] pub(crate) struct UnrecognizedPlatformCheck; @@ -74,7 +74,7 @@ impl Violation for UnrecognizedPlatformCheck { /// ``` /// /// ## References -/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks) +/// - [Typing documentation: Version and Platform checking](https://typing.python.org/en/latest/spec/directives.html#version-and-platform-checks) #[derive(ViolationMetadata)] pub(crate) struct UnrecognizedPlatformName { platform: String, diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs index 9588fe350f..72a20ed3c2 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs @@ -31,7 +31,7 @@ use crate::registry::Rule; /// ``` /// /// ## References -/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks) +/// - [Typing documentation: Version and Platform checking](https://typing.python.org/en/latest/spec/directives.html#version-and-platform-checks) #[derive(ViolationMetadata)] pub(crate) struct UnrecognizedVersionInfoCheck; @@ -70,7 +70,7 @@ impl Violation for UnrecognizedVersionInfoCheck { /// ``` /// /// ## References -/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks) +/// - [Typing documentation: Version and Platform checking](https://typing.python.org/en/latest/spec/directives.html#version-and-platform-checks) #[derive(ViolationMetadata)] pub(crate) struct PatchVersionComparison; @@ -106,7 +106,7 @@ impl Violation for PatchVersionComparison { /// ``` /// /// ## References -/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks) +/// - [Typing documentation: Version and Platform checking](https://typing.python.org/en/latest/spec/directives.html#version-and-platform-checks) #[derive(ViolationMetadata)] pub(crate) struct WrongTupleLengthVersionComparison { expected_length: usize, diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs index c7e2765204..87400d64bd 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs @@ -63,7 +63,7 @@ const BLANK_LINES_NESTED_LEVEL: u32 = 1; /// ## References /// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines) /// - [Flake 8 rule](https://www.flake8rules.com/rules/E301.html) -/// - [Typing Style Guide](https://typing.readthedocs.io/en/latest/source/stubs.html#blank-lines) +/// - [Typing Style Guide](https://typing.python.org/en/latest/source/stubs.html#blank-lines) #[derive(ViolationMetadata)] pub(crate) struct BlankLineBetweenMethods; @@ -116,7 +116,7 @@ impl AlwaysFixableViolation for BlankLineBetweenMethods { /// ## References /// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines) /// - [Flake 8 rule](https://www.flake8rules.com/rules/E302.html) -/// - [Typing Style Guide](https://typing.readthedocs.io/en/latest/source/stubs.html#blank-lines) +/// - [Typing Style Guide](https://typing.python.org/en/latest/source/stubs.html#blank-lines) #[derive(ViolationMetadata)] pub(crate) struct BlankLinesTopLevel { actual_blank_lines: u32, @@ -183,7 +183,7 @@ impl AlwaysFixableViolation for BlankLinesTopLevel { /// ## References /// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines) /// - [Flake 8 rule](https://www.flake8rules.com/rules/E303.html) -/// - [Typing Style Guide](https://typing.readthedocs.io/en/latest/source/stubs.html#blank-lines) +/// - [Typing Style Guide](https://typing.python.org/en/latest/source/stubs.html#blank-lines) #[derive(ViolationMetadata)] pub(crate) struct TooManyBlankLines { actual_blank_lines: u32, @@ -280,7 +280,7 @@ impl AlwaysFixableViolation for BlankLineAfterDecorator { /// ## References /// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines) /// - [Flake 8 rule](https://www.flake8rules.com/rules/E305.html) -/// - [Typing Style Guide](https://typing.readthedocs.io/en/latest/source/stubs.html#blank-lines) +/// - [Typing Style Guide](https://typing.python.org/en/latest/source/stubs.html#blank-lines) #[derive(ViolationMetadata)] pub(crate) struct BlankLinesAfterFunctionOrClass { actual_blank_lines: u32, @@ -334,7 +334,7 @@ impl AlwaysFixableViolation for BlankLinesAfterFunctionOrClass { /// ## References /// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines) /// - [Flake 8 rule](https://www.flake8rules.com/rules/E306.html) -/// - [Typing Style Guide](https://typing.readthedocs.io/en/latest/source/stubs.html#blank-lines) +/// - [Typing Style Guide](https://typing.python.org/en/latest/source/stubs.html#blank-lines) #[derive(ViolationMetadata)] pub(crate) struct BlankLinesBeforeNestedDefinition; diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs index 1716b84b7f..1a9af61beb 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs @@ -94,7 +94,7 @@ use crate::rules::{isort, isort::ImportSection, isort::ImportType}; /// ## References /// - [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement) /// - [Python documentation: `importlib.util.find_spec`](https://docs.python.org/3/library/importlib.html#importlib.util.find_spec) -/// - [Typing documentation: interface conventions](https://typing.readthedocs.io/en/latest/source/libraries.html#library-interface-public-and-private-symbols) +/// - [Typing documentation: interface conventions](https://typing.python.org/en/latest/source/libraries.html#library-interface-public-and-private-symbols) #[derive(ViolationMetadata)] pub(crate) struct UnusedImport { /// Qualified name of the import diff --git a/crates/ruff_linter/src/rules/ruff/rules/redundant_bool_literal.rs b/crates/ruff_linter/src/rules/ruff/rules/redundant_bool_literal.rs index 7adb5e26c0..3ab76f994b 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/redundant_bool_literal.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/redundant_bool_literal.rs @@ -48,7 +48,7 @@ use crate::checkers::ast::Checker; /// Further, the `Literal` slice may contain trailing-line comments which the fix would remove. /// /// ## References -/// - [Typing documentation: Legal parameters for `Literal` at type check time](https://typing.readthedocs.io/en/latest/spec/literal.html#legal-parameters-for-literal-at-type-check-time) +/// - [Typing documentation: Legal parameters for `Literal` at type check time](https://typing.python.org/en/latest/spec/literal.html#legal-parameters-for-literal-at-type-check-time) /// - [Python documentation: Boolean type - `bool`](https://docs.python.org/3/library/stdtypes.html#boolean-type-bool) /// /// [mypy]: https://github.com/python/mypy/blob/master/mypy/typeops.py#L985 diff --git a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs index 948e211190..772f65ded5 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs @@ -55,7 +55,7 @@ use crate::checkers::ast::Checker; /// across multiple lines and some of the lines have trailing comments. /// /// ## References -/// - [Typing documentation: Legal parameters for `Literal` at type check time](https://typing.readthedocs.io/en/latest/spec/literal.html#legal-parameters-for-literal-at-type-check-time) +/// - [Typing documentation: Legal parameters for `Literal` at type check time](https://typing.python.org/en/latest/spec/literal.html#legal-parameters-for-literal-at-type-check-time) /// /// [PEP 586](https://peps.python.org/pep-0586/) #[derive(ViolationMetadata)] diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index a549ab9093..fa83cd684d 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -316,7 +316,7 @@ pub struct Options { /// for a complete description of how the `target-version` is determined /// when left unspecified. /// - /// Note that a stub file can [sometimes make use of a typing feature](https://typing.readthedocs.io/en/latest/spec/distributing.html#syntax) + /// Note that a stub file can [sometimes make use of a typing feature](https://typing.python.org/en/latest/spec/distributing.html#syntax) /// before it is available at runtime, as long as the stub does not make /// use of new *syntax*. For example, a type checker will understand /// `int | str` in a stub as being a `Union` type annotation, even if the @@ -2427,7 +2427,7 @@ pub struct IsortOptions { /// Use `-1` for automatic determination. /// /// Ruff uses at most one blank line after imports in typing stub files (files with `.pyi` extension) in accordance to - /// the typing style recommendations ([source](https://typing.readthedocs.io/en/latest/guides/writing_stubs.html#blank-lines)). + /// the typing style recommendations ([source](https://typing.python.org/en/latest/guides/writing_stubs.html#blank-lines)). /// /// When using the formatter, only the values `-1`, `1`, and `2` are compatible because /// it enforces at least one empty and at most two empty lines after imports. diff --git a/ruff.schema.json b/ruff.schema.json index ec46aedbc8..16d78a3789 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -702,7 +702,7 @@ } }, "target-version": { - "description": "The minimum Python version to target, e.g., when considering automatic code upgrades, like rewriting type annotations. Ruff will not propose changes using features that are not available in the given version.\n\nFor example, to represent supporting Python >=3.10 or ==3.10 specify `target-version = \"py310\"`.\n\nIf you're already using a `pyproject.toml` file, we recommend `project.requires-python` instead, as it's based on Python packaging standards, and will be respected by other tools. For example, Ruff treats the following as identical to `target-version = \"py38\"`:\n\n```toml [project] requires-python = \">=3.8\" ```\n\nIf both are specified, `target-version` takes precedence over `requires-python`. See [_Inferring the Python version_](https://docs.astral.sh/ruff/configuration/#inferring-the-python-version) for a complete description of how the `target-version` is determined when left unspecified.\n\nNote that a stub file can [sometimes make use of a typing feature](https://typing.readthedocs.io/en/latest/spec/distributing.html#syntax) before it is available at runtime, as long as the stub does not make use of new *syntax*. For example, a type checker will understand `int | str` in a stub as being a `Union` type annotation, even if the type checker is run using Python 3.9, despite the fact that the `|` operator can only be used to create union types at runtime on Python 3.10+. As such, Ruff will often recommend newer features in a stub file than it would for an equivalent runtime file with the same target version.", + "description": "The minimum Python version to target, e.g., when considering automatic code upgrades, like rewriting type annotations. Ruff will not propose changes using features that are not available in the given version.\n\nFor example, to represent supporting Python >=3.10 or ==3.10 specify `target-version = \"py310\"`.\n\nIf you're already using a `pyproject.toml` file, we recommend `project.requires-python` instead, as it's based on Python packaging standards, and will be respected by other tools. For example, Ruff treats the following as identical to `target-version = \"py38\"`:\n\n```toml [project] requires-python = \">=3.8\" ```\n\nIf both are specified, `target-version` takes precedence over `requires-python`. See [_Inferring the Python version_](https://docs.astral.sh/ruff/configuration/#inferring-the-python-version) for a complete description of how the `target-version` is determined when left unspecified.\n\nNote that a stub file can [sometimes make use of a typing feature](https://typing.python.org/en/latest/spec/distributing.html#syntax) before it is available at runtime, as long as the stub does not make use of new *syntax*. For example, a type checker will understand `int | str` in a stub as being a `Union` type annotation, even if the type checker is run using Python 3.9, despite the fact that the `|` operator can only be used to create union types at runtime on Python 3.10+. As such, Ruff will often recommend newer features in a stub file than it would for an equivalent runtime file with the same target version.", "anyOf": [ { "$ref": "#/definitions/PythonVersion" @@ -1800,7 +1800,7 @@ ] }, "lines-after-imports": { - "description": "The number of blank lines to place after imports. Use `-1` for automatic determination.\n\nRuff uses at most one blank line after imports in typing stub files (files with `.pyi` extension) in accordance to the typing style recommendations ([source](https://typing.readthedocs.io/en/latest/guides/writing_stubs.html#blank-lines)).\n\nWhen using the formatter, only the values `-1`, `1`, and `2` are compatible because it enforces at least one empty and at most two empty lines after imports.", + "description": "The number of blank lines to place after imports. Use `-1` for automatic determination.\n\nRuff uses at most one blank line after imports in typing stub files (files with `.pyi` extension) in accordance to the typing style recommendations ([source](https://typing.python.org/en/latest/guides/writing_stubs.html#blank-lines)).\n\nWhen using the formatter, only the values `-1`, `1`, and `2` are compatible because it enforces at least one empty and at most two empty lines after imports.", "type": [ "integer", "null"