mirror of https://github.com/astral-sh/ruff
Add `target-version` link to relevant rules (#5105)
This commit is contained in:
parent
458beccf14
commit
9ab16fb417
|
|
@ -49,6 +49,9 @@ use crate::checkers::ast::Checker;
|
|||
/// def func(obj: dict[str, int | None]) -> None:
|
||||
/// ...
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
#[violation]
|
||||
pub struct FutureRewritableTypeAnnotation {
|
||||
name: String,
|
||||
|
|
|
|||
|
|
@ -17,16 +17,30 @@ use crate::settings::types::PythonVersion;
|
|||
/// trailing ends of the string. Including duplicate characters in the call
|
||||
/// is redundant and often indicative of a mistake.
|
||||
///
|
||||
/// In Python 3.9 and later, you can use `str#removeprefix` and
|
||||
/// `str#removesuffix` to remove an exact prefix or suffix from a string,
|
||||
/// respectively, which should be preferred when possible.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// "bar foo baz".strip("bar baz ") # "foo"
|
||||
/// # Evaluates to "foo".
|
||||
/// "bar foo baz".strip("bar baz ")
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// # Evaluates to "foo".
|
||||
/// "bar foo baz".strip("abrz ") # "foo"
|
||||
/// ```
|
||||
///
|
||||
/// Or:
|
||||
/// ```python
|
||||
/// # Evaluates to "foo".
|
||||
/// "bar foo baz".removeprefix("bar ").removesuffix(" baz")
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// ## References
|
||||
/// - [Python documentation](https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.strip)
|
||||
#[violation]
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ use crate::checkers::ast::Checker;
|
|||
/// else:
|
||||
/// continue
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
#[violation]
|
||||
pub struct ContinueInFinally;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ use crate::settings::types::PythonVersion;
|
|||
/// return isinstance(x, int | float | complex)
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance)
|
||||
#[violation]
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ use crate::registry::AsRule;
|
|||
/// datetime.UTC
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `datetime.UTC`](https://docs.python.org/3/library/datetime.html#datetime.UTC)
|
||||
#[violation]
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ use crate::registry::AsRule;
|
|||
/// ...
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `@functools.cache`](https://docs.python.org/3/library/functools.html#functools.cache)
|
||||
#[violation]
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ use crate::registry::AsRule;
|
|||
/// ...
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `@functools.lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache)
|
||||
/// - [Let lru_cache be used as a decorator with no arguments](https://github.com/python/cpython/issues/80953)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ use crate::settings::types::PythonVersion;
|
|||
/// print("py3")
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||
#[violation]
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ use crate::registry::AsRule;
|
|||
/// print("Hello, world!")
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `__future__` — Future statement definitions](https://docs.python.org/3/library/__future__.html)
|
||||
#[violation]
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ use crate::registry::AsRule;
|
|||
/// foo: list[int] = [1, 2, 3]
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// [PEP 585]: https://peps.python.org/pep-0585/
|
||||
#[violation]
|
||||
pub struct NonPEP585Annotation {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ use crate::registry::AsRule;
|
|||
/// foo: int | str = 1
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// [PEP 604]: https://peps.python.org/pep-0604/
|
||||
#[violation]
|
||||
pub struct NonPEP604Annotation;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ impl CallKind {
|
|||
/// isinstance(x, int | float)
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance)
|
||||
/// - [Python documentation: `issubclass`](https://docs.python.org/3/library/functions.html#issubclass)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ use crate::settings::types::PythonVersion;
|
|||
/// pass
|
||||
/// ```
|
||||
///
|
||||
/// ## Options
|
||||
/// - `target-version`
|
||||
///
|
||||
/// [PEP 484]: https://peps.python.org/pep-0484/#union-types
|
||||
#[violation]
|
||||
pub struct ImplicitOptional {
|
||||
|
|
|
|||
Loading…
Reference in New Issue