Add `target-version` link to relevant rules (#5105)

This commit is contained in:
Charlie Marsh 2023-06-14 20:12:32 -04:00 committed by GitHub
parent 458beccf14
commit 9ab16fb417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 51 additions and 1 deletions

View File

@ -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,

View File

@ -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]

View File

@ -32,6 +32,9 @@ use crate::checkers::ast::Checker;
/// else:
/// continue
/// ```
///
/// ## Options
/// - `target-version`
#[violation]
pub struct ContinueInFinally;

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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)

View File

@ -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]

View File

@ -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]

View File

@ -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 {

View File

@ -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;

View File

@ -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)

View File

@ -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 {