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: /// def func(obj: dict[str, int | None]) -> None:
/// ... /// ...
/// ``` /// ```
///
/// ## Options
/// - `target-version`
#[violation] #[violation]
pub struct FutureRewritableTypeAnnotation { pub struct FutureRewritableTypeAnnotation {
name: String, name: String,

View File

@ -17,16 +17,30 @@ use crate::settings::types::PythonVersion;
/// trailing ends of the string. Including duplicate characters in the call /// trailing ends of the string. Including duplicate characters in the call
/// is redundant and often indicative of a mistake. /// 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 /// ## Example
/// ```python /// ```python
/// "bar foo baz".strip("bar baz ") # "foo" /// # Evaluates to "foo".
/// "bar foo baz".strip("bar baz ")
/// ``` /// ```
/// ///
/// Use instead: /// Use instead:
/// ```python /// ```python
/// # Evaluates to "foo".
/// "bar foo baz".strip("abrz ") # "foo" /// "bar foo baz".strip("abrz ") # "foo"
/// ``` /// ```
/// ///
/// Or:
/// ```python
/// # Evaluates to "foo".
/// "bar foo baz".removeprefix("bar ").removesuffix(" baz")
///
/// ## Options
/// - `target-version`
///
/// ## References /// ## References
/// - [Python documentation](https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.strip) /// - [Python documentation](https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.strip)
#[violation] #[violation]

View File

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

View File

@ -36,6 +36,9 @@ use crate::settings::types::PythonVersion;
/// return isinstance(x, int | float | complex) /// return isinstance(x, int | float | complex)
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// ## References /// ## References
/// - [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance) /// - [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance)
#[violation] #[violation]

View File

@ -28,6 +28,9 @@ use crate::registry::AsRule;
/// datetime.UTC /// datetime.UTC
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// ## References /// ## References
/// - [Python documentation: `datetime.UTC`](https://docs.python.org/3/library/datetime.html#datetime.UTC) /// - [Python documentation: `datetime.UTC`](https://docs.python.org/3/library/datetime.html#datetime.UTC)
#[violation] #[violation]

View File

@ -36,6 +36,9 @@ use crate::registry::AsRule;
/// ... /// ...
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// ## References /// ## References
/// - [Python documentation: `@functools.cache`](https://docs.python.org/3/library/functools.html#functools.cache) /// - [Python documentation: `@functools.cache`](https://docs.python.org/3/library/functools.html#functools.cache)
#[violation] #[violation]

View File

@ -34,6 +34,9 @@ use crate::registry::AsRule;
/// ... /// ...
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// ## References /// ## References
/// - [Python documentation: `@functools.lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache) /// - [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) /// - [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") /// print("py3")
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// ## References /// ## References
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info) /// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
#[violation] #[violation]

View File

@ -30,6 +30,9 @@ use crate::registry::AsRule;
/// print("Hello, world!") /// print("Hello, world!")
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// ## References /// ## References
/// - [Python documentation: `__future__` — Future statement definitions](https://docs.python.org/3/library/__future__.html) /// - [Python documentation: `__future__` — Future statement definitions](https://docs.python.org/3/library/__future__.html)
#[violation] #[violation]

View File

@ -35,6 +35,9 @@ use crate::registry::AsRule;
/// foo: list[int] = [1, 2, 3] /// foo: list[int] = [1, 2, 3]
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// [PEP 585]: https://peps.python.org/pep-0585/ /// [PEP 585]: https://peps.python.org/pep-0585/
#[violation] #[violation]
pub struct NonPEP585Annotation { pub struct NonPEP585Annotation {

View File

@ -28,6 +28,9 @@ use crate::registry::AsRule;
/// foo: int | str = 1 /// foo: int | str = 1
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// [PEP 604]: https://peps.python.org/pep-0604/ /// [PEP 604]: https://peps.python.org/pep-0604/
#[violation] #[violation]
pub struct NonPEP604Annotation; pub struct NonPEP604Annotation;

View File

@ -53,6 +53,9 @@ impl CallKind {
/// isinstance(x, int | float) /// isinstance(x, int | float)
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// ## References /// ## References
/// - [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance) /// - [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance)
/// - [Python documentation: `issubclass`](https://docs.python.org/3/library/functions.html#issubclass) /// - [Python documentation: `issubclass`](https://docs.python.org/3/library/functions.html#issubclass)

View File

@ -55,6 +55,9 @@ use crate::settings::types::PythonVersion;
/// pass /// pass
/// ``` /// ```
/// ///
/// ## Options
/// - `target-version`
///
/// [PEP 484]: https://peps.python.org/pep-0484/#union-types /// [PEP 484]: https://peps.python.org/pep-0484/#union-types
#[violation] #[violation]
pub struct ImplicitOptional { pub struct ImplicitOptional {