mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +00:00
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:
parent
144484d46c
commit
5fef4d4572
37 changed files with 57 additions and 57 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
References:
|
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:
|
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
|
<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
|
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
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
In order to support common use cases, an annotation of `float` actually means `int | float`, and an
|
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
|
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
|
## float
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Literal
|
# Literal
|
||||||
|
|
||||||
<https://typing.readthedocs.io/en/latest/spec/literal.html#literals>
|
<https://typing.python.org/en/latest/spec/literal.html#literals>
|
||||||
|
|
||||||
## Parameterization
|
## Parameterization
|
||||||
|
|
||||||
|
|
|
@ -147,4 +147,4 @@ def f():
|
||||||
reveal_type(x) # revealed: LiteralString
|
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
|
||||||
|
|
|
@ -1800,5 +1800,5 @@ Some of the tests in the *Class and instance variables* section draw inspiration
|
||||||
|
|
||||||
[descriptor protocol tests]: descriptor_protocol.md
|
[descriptor protocol tests]: descriptor_protocol.md
|
||||||
[pyright's documentation]: https://microsoft.github.io/pyright/#/type-concepts-advanced?id=class-and-instance-variables
|
[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
|
[`typing.classvar`]: https://docs.python.org/3/library/typing.html#typing.ClassVar
|
||||||
|
|
|
@ -122,4 +122,4 @@ class Wrapper:
|
||||||
reveal_type(Wrapper.value) # revealed: Unknown | None
|
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
|
||||||
|
|
|
@ -69,4 +69,4 @@ from typing import TypeVar
|
||||||
T = TypeVar("T", int)
|
T = TypeVar("T", int)
|
||||||
```
|
```
|
||||||
|
|
||||||
[generics]: https://typing.readthedocs.io/en/latest/spec/generics.html
|
[generics]: https://typing.python.org/en/latest/spec/generics.html
|
||||||
|
|
|
@ -299,4 +299,4 @@ class C[T]:
|
||||||
ok2: Inner[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
|
||||||
|
|
|
@ -4,7 +4,7 @@ This document describes the conventions for importing symbols.
|
||||||
|
|
||||||
Reference:
|
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
|
## Builtins scope
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
> If a type checker supports the `no_type_check` decorator for functions, it should suppress all
|
> 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
|
> 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
|
> 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
|
## 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`
|
Red Knot does not support decorating classes with `no_type_check`. The behaviour of `no_type_check`
|
||||||
when applied to classes is
|
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.
|
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
|
A future improvement might be to emit a diagnostic if a `no_type_check` annotation is applied to a
|
||||||
|
|
|
@ -504,4 +504,4 @@ c: Callable[[Any], str] = f
|
||||||
c: Callable[[Any], str] = g
|
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
|
||||||
|
|
|
@ -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))
|
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
|
||||||
|
|
|
@ -157,4 +157,4 @@ def f6(a, /): ...
|
||||||
static_assert(not is_gradual_equivalent_to(CallableTypeOf[f1], CallableTypeOf[f6]))
|
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
|
||||||
|
|
|
@ -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]))
|
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
|
[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.readthedocs.io/en/latest/spec/concepts.html#subtype-supertype-and-type-equivalence
|
[typing documentation]: https://typing.python.org/en/latest/spec/concepts.html#subtype-supertype-and-type-equivalence
|
||||||
|
|
|
@ -168,7 +168,7 @@ impl SearchPaths {
|
||||||
///
|
///
|
||||||
/// This method also implements the typing spec's [module resolution order].
|
/// 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(
|
pub(crate) fn from_settings(
|
||||||
db: &dyn Db,
|
db: &dyn Db,
|
||||||
settings: &SearchPathSettings,
|
settings: &SearchPathSettings,
|
||||||
|
|
|
@ -535,7 +535,7 @@ impl<'a> SuppressionsBuilder<'a> {
|
||||||
// > imports, or other executable code, silences all errors in the file.
|
// > imports, or other executable code, silences all errors in the file.
|
||||||
// > Blank lines and other comments, such as shebang lines and coding cookies,
|
// > Blank lines and other comments, such as shebang lines and coding cookies,
|
||||||
// > may precede the # type: ignore comment.
|
// > 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 is_file_suppression = comment.kind.is_type_ignore() && !self.seen_non_trivia_token;
|
||||||
|
|
||||||
let suppressed_range = if is_file_suppression {
|
let suppressed_range = if is_file_suppression {
|
||||||
|
|
|
@ -766,7 +766,7 @@ impl<'db> Type<'db> {
|
||||||
///
|
///
|
||||||
/// This method returns `false` if either `self` or `other` is not fully static.
|
/// 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 {
|
pub(crate) fn is_subtype_of(self, db: &'db dyn Db, target: Type<'db>) -> bool {
|
||||||
// Two equivalent types are always subtypes of each other.
|
// 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`.
|
/// 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 {
|
pub(crate) fn is_assignable_to(self, db: &'db dyn Db, target: Type<'db>) -> bool {
|
||||||
if self.is_gradual_equivalent_to(db, target) {
|
if self.is_gradual_equivalent_to(db, target) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1274,7 +1274,7 @@ impl<'db> Type<'db> {
|
||||||
///
|
///
|
||||||
/// This method returns `false` if either `self` or `other` is not fully static.
|
/// 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 {
|
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.
|
// 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.
|
/// 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 {
|
pub(crate) fn is_gradual_equivalent_to(self, db: &'db dyn Db, other: Type<'db>) -> bool {
|
||||||
if self == other {
|
if self == other {
|
||||||
return true;
|
return true;
|
||||||
|
@ -3857,7 +3857,7 @@ impl<'db> Type<'db> {
|
||||||
) -> Result<Type<'db>, InvalidTypeExpressionError<'db>> {
|
) -> Result<Type<'db>, InvalidTypeExpressionError<'db>> {
|
||||||
match self {
|
match self {
|
||||||
// Special cases for `float` and `complex`
|
// 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) => {
|
Type::ClassLiteral(class) => {
|
||||||
let ty = match class.known(db) {
|
let ty = match class.known(db) {
|
||||||
Some(KnownClass::Any) => Type::any(),
|
Some(KnownClass::Any) => Type::any(),
|
||||||
|
@ -5462,7 +5462,7 @@ pub enum KnownFunction {
|
||||||
/// `typing(_extensions).final`
|
/// `typing(_extensions).final`
|
||||||
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,
|
NoTypeCheck,
|
||||||
|
|
||||||
/// `typing(_extensions).assert_type`
|
/// `typing(_extensions).assert_type`
|
||||||
|
|
|
@ -6223,9 +6223,9 @@ impl<'db> TypeInferenceBuilder<'db> {
|
||||||
&mut self,
|
&mut self,
|
||||||
annotation: &ast::Expr,
|
annotation: &ast::Expr,
|
||||||
) -> TypeAndQualifiers<'db> {
|
) -> 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 {
|
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),
|
ast::Expr::StringLiteral(string) => self.infer_string_annotation_expression(string),
|
||||||
|
|
||||||
// Annotation expressions also get special handling for `*args` and `**kwargs`.
|
// 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.
|
/// Infer the type of a type expression without storing the result.
|
||||||
fn infer_type_expression_no_store(&mut self, expression: &ast::Expr) -> Type<'db> {
|
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 {
|
match expression {
|
||||||
ast::Expr::Name(name) => match name.ctx {
|
ast::Expr::Name(name) => match name.ctx {
|
||||||
ast::ExprContext::Load => self
|
ast::ExprContext::Load => self
|
||||||
|
@ -6446,7 +6446,7 @@ impl<'db> TypeInferenceBuilder<'db> {
|
||||||
|
|
||||||
ast::Expr::NoneLiteral(_literal) => Type::none(self.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::StringLiteral(string) => self.infer_string_type_expression(string),
|
||||||
|
|
||||||
ast::Expr::Subscript(subscript) => {
|
ast::Expr::Subscript(subscript) => {
|
||||||
|
|
|
@ -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.**
|
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
|
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.
|
Typeshed supports Python versions 3.9 to 3.13.
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,6 @@ else:
|
||||||
## References
|
## References
|
||||||
- [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement)
|
- [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)
|
- [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 -----
|
----- stderr -----
|
||||||
|
|
|
@ -81,7 +81,7 @@ expression: value
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"fullDescription": {
|
"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": {
|
"help": {
|
||||||
"text": "`{name}` imported but unused; consider using `importlib.util.find_spec` to test for availability"
|
"text": "`{name}` imported but unused; consider using `importlib.util.find_spec` to test for availability"
|
||||||
|
|
|
@ -480,7 +480,7 @@ impl Violation for MissingReturnTypeClassMethod {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)
|
/// - [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)
|
/// - [Mypy documentation: The Any type](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#the-any-type)
|
||||||
#[derive(ViolationMetadata)]
|
#[derive(ViolationMetadata)]
|
||||||
|
|
|
@ -30,7 +30,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct ComplexIfStatementInStub;
|
pub(crate) struct ComplexIfStatementInStub;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::{checkers::ast::Checker, fix};
|
||||||
/// statement has no effect and should be omitted.
|
/// statement has no effect and should be omitted.
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct FutureAnnotationsInStub;
|
pub(crate) struct FutureAnnotationsInStub;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct NonEmptyStubBody;
|
pub(crate) struct NonEmptyStubBody;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct PassStatementStubBody;
|
pub(crate) struct PassStatementStubBody;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct QuotedAnnotationInStub;
|
pub(crate) struct QuotedAnnotationInStub;
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ use crate::{checkers::ast::Checker, importer::ImportRequest};
|
||||||
/// is 3.9 or below.
|
/// is 3.9 or below.
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct RedundantNoneLiteral {
|
pub(crate) struct RedundantNoneLiteral {
|
||||||
union_kind: UnionKind,
|
union_kind: UnionKind,
|
||||||
|
|
|
@ -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)
|
/// - [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)
|
/// - [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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct RedundantNumericUnion {
|
pub(crate) struct RedundantNumericUnion {
|
||||||
redundancy: Redundancy,
|
redundancy: Redundancy,
|
||||||
|
|
|
@ -40,7 +40,7 @@ use crate::registry::Rule;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct UnrecognizedPlatformCheck;
|
pub(crate) struct UnrecognizedPlatformCheck;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ impl Violation for UnrecognizedPlatformCheck {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct UnrecognizedPlatformName {
|
pub(crate) struct UnrecognizedPlatformName {
|
||||||
platform: String,
|
platform: String,
|
||||||
|
|
|
@ -31,7 +31,7 @@ use crate::registry::Rule;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct UnrecognizedVersionInfoCheck;
|
pub(crate) struct UnrecognizedVersionInfoCheck;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ impl Violation for UnrecognizedVersionInfoCheck {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct PatchVersionComparison;
|
pub(crate) struct PatchVersionComparison;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ impl Violation for PatchVersionComparison {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct WrongTupleLengthVersionComparison {
|
pub(crate) struct WrongTupleLengthVersionComparison {
|
||||||
expected_length: usize,
|
expected_length: usize,
|
||||||
|
|
|
@ -63,7 +63,7 @@ const BLANK_LINES_NESTED_LEVEL: u32 = 1;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
||||||
/// - [Flake 8 rule](https://www.flake8rules.com/rules/E301.html)
|
/// - [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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct BlankLineBetweenMethods;
|
pub(crate) struct BlankLineBetweenMethods;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ impl AlwaysFixableViolation for BlankLineBetweenMethods {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
||||||
/// - [Flake 8 rule](https://www.flake8rules.com/rules/E302.html)
|
/// - [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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct BlankLinesTopLevel {
|
pub(crate) struct BlankLinesTopLevel {
|
||||||
actual_blank_lines: u32,
|
actual_blank_lines: u32,
|
||||||
|
@ -183,7 +183,7 @@ impl AlwaysFixableViolation for BlankLinesTopLevel {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
||||||
/// - [Flake 8 rule](https://www.flake8rules.com/rules/E303.html)
|
/// - [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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct TooManyBlankLines {
|
pub(crate) struct TooManyBlankLines {
|
||||||
actual_blank_lines: u32,
|
actual_blank_lines: u32,
|
||||||
|
@ -280,7 +280,7 @@ impl AlwaysFixableViolation for BlankLineAfterDecorator {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
||||||
/// - [Flake 8 rule](https://www.flake8rules.com/rules/E305.html)
|
/// - [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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct BlankLinesAfterFunctionOrClass {
|
pub(crate) struct BlankLinesAfterFunctionOrClass {
|
||||||
actual_blank_lines: u32,
|
actual_blank_lines: u32,
|
||||||
|
@ -334,7 +334,7 @@ impl AlwaysFixableViolation for BlankLinesAfterFunctionOrClass {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
/// - [PEP 8: Blank Lines](https://peps.python.org/pep-0008/#blank-lines)
|
||||||
/// - [Flake 8 rule](https://www.flake8rules.com/rules/E306.html)
|
/// - [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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct BlankLinesBeforeNestedDefinition;
|
pub(crate) struct BlankLinesBeforeNestedDefinition;
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ use crate::rules::{isort, isort::ImportSection, isort::ImportType};
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement)
|
/// - [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)
|
/// - [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)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct UnusedImport {
|
pub(crate) struct UnusedImport {
|
||||||
/// Qualified name of the import
|
/// Qualified name of the import
|
||||||
|
|
|
@ -48,7 +48,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// Further, the `Literal` slice may contain trailing-line comments which the fix would remove.
|
/// Further, the `Literal` slice may contain trailing-line comments which the fix would remove.
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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)
|
/// - [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
|
/// [mypy]: https://github.com/python/mypy/blob/master/mypy/typeops.py#L985
|
||||||
|
|
|
@ -55,7 +55,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// across multiple lines and some of the lines have trailing comments.
|
/// across multiple lines and some of the lines have trailing comments.
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## 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/)
|
/// [PEP 586](https://peps.python.org/pep-0586/)
|
||||||
#[derive(ViolationMetadata)]
|
#[derive(ViolationMetadata)]
|
||||||
|
|
|
@ -316,7 +316,7 @@ pub struct Options {
|
||||||
/// for a complete description of how the `target-version` is determined
|
/// for a complete description of how the `target-version` is determined
|
||||||
/// when left unspecified.
|
/// 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
|
/// 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
|
/// 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
|
/// `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.
|
/// 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
|
/// 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
|
/// 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.
|
/// it enforces at least one empty and at most two empty lines after imports.
|
||||||
|
|
4
ruff.schema.json
generated
4
ruff.schema.json
generated
|
@ -702,7 +702,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"target-version": {
|
"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": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/PythonVersion"
|
"$ref": "#/definitions/PythonVersion"
|
||||||
|
@ -1800,7 +1800,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"lines-after-imports": {
|
"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": [
|
"type": [
|
||||||
"integer",
|
"integer",
|
||||||
"null"
|
"null"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue