Remove erroneous method calls in flake8-unused-arguments docs (#4771)

This commit is contained in:
Charlie Marsh 2023-05-31 22:23:59 -04:00 committed by GitHub
parent 1156c65be1
commit 3d34d9298d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,13 +13,13 @@ use ruff_python_semantic::analyze::visibility;
use ruff_python_semantic::binding::Bindings; use ruff_python_semantic::binding::Bindings;
use ruff_python_semantic::scope::{Scope, ScopeKind}; use ruff_python_semantic::scope::{Scope, ScopeKind};
use super::super::helpers;
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::registry::Rule; use crate::registry::Rule;
use super::super::helpers;
/// An AST node that can contain arguments. /// An AST node that can contain arguments.
#[derive(Copy, Clone)] #[derive(Debug, Copy, Clone)]
enum Argumentable { enum Argumentable {
Function, Function,
Method, Method,
@ -29,7 +29,7 @@ enum Argumentable {
} }
impl Argumentable { impl Argumentable {
pub(crate) fn check_for(self, name: String) -> DiagnosticKind { fn check_for(self, name: String) -> DiagnosticKind {
match self { match self {
Self::Function => UnusedFunctionArgument { name }.into(), Self::Function => UnusedFunctionArgument { name }.into(),
Self::Method => UnusedMethodArgument { name }.into(), Self::Method => UnusedMethodArgument { name }.into(),
@ -39,7 +39,7 @@ impl Argumentable {
} }
} }
pub(crate) const fn rule_code(self) -> Rule { const fn rule_code(self) -> Rule {
match self { match self {
Self::Function => Rule::UnusedFunctionArgument, Self::Function => Rule::UnusedFunctionArgument,
Self::Method => Rule::UnusedMethodArgument, Self::Method => Rule::UnusedMethodArgument,
@ -90,15 +90,15 @@ impl Violation for UnusedFunctionArgument {
/// ///
/// ## Example /// ## Example
/// ```python /// ```python
/// class MyClass: /// class Class:
/// def my_method(self, arg1, arg2): /// def foo(self, arg1, arg2):
/// print(arg1) /// print(arg1)
/// ``` /// ```
/// ///
/// Use instead: /// Use instead:
/// ```python /// ```python
/// class MyClass: /// class Class:
/// def my_method(self, arg1): /// def foo(self, arg1):
/// print(arg1) /// print(arg1)
/// ``` /// ```
#[violation] #[violation]
@ -123,24 +123,18 @@ impl Violation for UnusedMethodArgument {
/// ///
/// ## Example /// ## Example
/// ```python /// ```python
/// class MyClass: /// class Class:
/// @classmethod /// @classmethod
/// def my_method(self, arg1, arg2): /// def foo(cls, arg1, arg2):
/// print(arg1) /// print(arg1)
///
/// def other_method(self):
/// self.my_method("foo", "bar")
/// ``` /// ```
/// ///
/// Use instead: /// Use instead:
/// ```python /// ```python
/// class MyClass: /// class Class:
/// @classmethod /// @classmethod
/// def my_method(self, arg1): /// def foo(cls, arg1):
/// print(arg1) /// print(arg1)
///
/// def other_method(self):
/// self.my_method("foo", "bar")
/// ``` /// ```
#[violation] #[violation]
pub struct UnusedClassMethodArgument { pub struct UnusedClassMethodArgument {
@ -164,24 +158,18 @@ impl Violation for UnusedClassMethodArgument {
/// ///
/// ## Example /// ## Example
/// ```python /// ```python
/// class MyClass: /// class Class:
/// @staticmethod /// @staticmethod
/// def my_static_method(self, arg1, arg2): /// def foo(arg1, arg2):
/// print(arg1) /// print(arg1)
///
/// def other_method(self):
/// self.my_static_method("foo", "bar")
/// ``` /// ```
/// ///
/// Use instead: /// Use instead:
/// ```python /// ```python
/// class MyClass: /// class Class:
/// @static /// @static
/// def my_static_method(self, arg1): /// def foo(arg1):
/// print(arg1) /// print(arg1)
///
/// def other_method(self):
/// self.my_static_method("foo", "bar")
/// ``` /// ```
#[violation] #[violation]
pub struct UnusedStaticMethodArgument { pub struct UnusedStaticMethodArgument {