mirror of https://github.com/astral-sh/ruff
Move flake8-annotations violations to rules file (#2496)
This commit is contained in:
parent
c3e0137f22
commit
739c57b31b
|
|
@ -175,17 +175,17 @@ ruff_macros::define_rule_mapping!(
|
||||||
Q002 => rules::flake8_quotes::rules::BadQuotesDocstring,
|
Q002 => rules::flake8_quotes::rules::BadQuotesDocstring,
|
||||||
Q003 => rules::flake8_quotes::rules::AvoidQuoteEscape,
|
Q003 => rules::flake8_quotes::rules::AvoidQuoteEscape,
|
||||||
// flake8-annotations
|
// flake8-annotations
|
||||||
ANN001 => violations::MissingTypeFunctionArgument,
|
ANN001 => rules::flake8_annotations::rules::MissingTypeFunctionArgument,
|
||||||
ANN002 => violations::MissingTypeArgs,
|
ANN002 => rules::flake8_annotations::rules::MissingTypeArgs,
|
||||||
ANN003 => violations::MissingTypeKwargs,
|
ANN003 => rules::flake8_annotations::rules::MissingTypeKwargs,
|
||||||
ANN101 => violations::MissingTypeSelf,
|
ANN101 => rules::flake8_annotations::rules::MissingTypeSelf,
|
||||||
ANN102 => violations::MissingTypeCls,
|
ANN102 => rules::flake8_annotations::rules::MissingTypeCls,
|
||||||
ANN201 => violations::MissingReturnTypePublicFunction,
|
ANN201 => rules::flake8_annotations::rules::MissingReturnTypePublicFunction,
|
||||||
ANN202 => violations::MissingReturnTypePrivateFunction,
|
ANN202 => rules::flake8_annotations::rules::MissingReturnTypePrivateFunction,
|
||||||
ANN204 => violations::MissingReturnTypeSpecialMethod,
|
ANN204 => rules::flake8_annotations::rules::MissingReturnTypeSpecialMethod,
|
||||||
ANN205 => violations::MissingReturnTypeStaticMethod,
|
ANN205 => rules::flake8_annotations::rules::MissingReturnTypeStaticMethod,
|
||||||
ANN206 => violations::MissingReturnTypeClassMethod,
|
ANN206 => rules::flake8_annotations::rules::MissingReturnTypeClassMethod,
|
||||||
ANN401 => violations::DynamicallyTypedExpression,
|
ANN401 => rules::flake8_annotations::rules::DynamicallyTypedExpression,
|
||||||
// flake8-2020
|
// flake8-2020
|
||||||
YTT101 => violations::SysVersionSlice3Referenced,
|
YTT101 => violations::SysVersionSlice3Referenced,
|
||||||
YTT102 => violations::SysVersion2Referenced,
|
YTT102 => violations::SysVersion2Referenced,
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,160 @@ use crate::ast::types::Range;
|
||||||
use crate::ast::visitor::Visitor;
|
use crate::ast::visitor::Visitor;
|
||||||
use crate::ast::{cast, helpers, visitor};
|
use crate::ast::{cast, helpers, visitor};
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
use crate::define_violation;
|
||||||
use crate::docstrings::definition::{Definition, DefinitionKind};
|
use crate::docstrings::definition::{Definition, DefinitionKind};
|
||||||
use crate::registry::{Diagnostic, Rule};
|
use crate::registry::{Diagnostic, Rule};
|
||||||
|
use crate::violation::{AlwaysAutofixableViolation, Violation};
|
||||||
|
use crate::visibility;
|
||||||
use crate::visibility::Visibility;
|
use crate::visibility::Visibility;
|
||||||
use crate::{violations, visibility};
|
use ruff_macros::derive_message_formats;
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingTypeFunctionArgument {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingTypeFunctionArgument {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingTypeFunctionArgument { name } = self;
|
||||||
|
format!("Missing type annotation for function argument `{name}`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingTypeArgs {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingTypeArgs {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingTypeArgs { name } = self;
|
||||||
|
format!("Missing type annotation for `*{name}`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingTypeKwargs {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingTypeKwargs {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingTypeKwargs { name } = self;
|
||||||
|
format!("Missing type annotation for `**{name}`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingTypeSelf {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingTypeSelf {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingTypeSelf { name } = self;
|
||||||
|
format!("Missing type annotation for `{name}` in method")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingTypeCls {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingTypeCls {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingTypeCls { name } = self;
|
||||||
|
format!("Missing type annotation for `{name}` in classmethod")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingReturnTypePublicFunction {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingReturnTypePublicFunction {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingReturnTypePublicFunction { name } = self;
|
||||||
|
format!("Missing return type annotation for public function `{name}`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingReturnTypePrivateFunction {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingReturnTypePrivateFunction {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingReturnTypePrivateFunction { name } = self;
|
||||||
|
format!("Missing return type annotation for private function `{name}`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingReturnTypeSpecialMethod {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl AlwaysAutofixableViolation for MissingReturnTypeSpecialMethod {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingReturnTypeSpecialMethod { name } = self;
|
||||||
|
format!("Missing return type annotation for special method `{name}`")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn autofix_title(&self) -> String {
|
||||||
|
"Add `None` return type".to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingReturnTypeStaticMethod {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingReturnTypeStaticMethod {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingReturnTypeStaticMethod { name } = self;
|
||||||
|
format!("Missing return type annotation for staticmethod `{name}`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct MissingReturnTypeClassMethod {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for MissingReturnTypeClassMethod {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let MissingReturnTypeClassMethod { name } = self;
|
||||||
|
format!("Missing return type annotation for classmethod `{name}`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_violation!(
|
||||||
|
pub struct DynamicallyTypedExpression {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
impl Violation for DynamicallyTypedExpression {
|
||||||
|
#[derive_message_formats]
|
||||||
|
fn message(&self) -> String {
|
||||||
|
let DynamicallyTypedExpression { name } = self;
|
||||||
|
format!("Dynamically typed expressions (typing.Any) are disallowed in `{name}`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ReturnStatementVisitor<'a> {
|
struct ReturnStatementVisitor<'a> {
|
||||||
|
|
@ -58,7 +208,7 @@ where
|
||||||
{
|
{
|
||||||
if checker.match_typing_expr(annotation, "Any") {
|
if checker.match_typing_expr(annotation, "Any") {
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::DynamicallyTypedExpression { name: func() },
|
DynamicallyTypedExpression { name: func() },
|
||||||
Range::from_located(annotation),
|
Range::from_located(annotation),
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
@ -115,7 +265,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
.enabled(&Rule::MissingTypeFunctionArgument)
|
.enabled(&Rule::MissingTypeFunctionArgument)
|
||||||
{
|
{
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingTypeFunctionArgument {
|
MissingTypeFunctionArgument {
|
||||||
name: arg.node.arg.to_string(),
|
name: arg.node.arg.to_string(),
|
||||||
},
|
},
|
||||||
Range::from_located(arg),
|
Range::from_located(arg),
|
||||||
|
|
@ -145,7 +295,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
{
|
{
|
||||||
if checker.settings.rules.enabled(&Rule::MissingTypeArgs) {
|
if checker.settings.rules.enabled(&Rule::MissingTypeArgs) {
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingTypeArgs {
|
MissingTypeArgs {
|
||||||
name: arg.node.arg.to_string(),
|
name: arg.node.arg.to_string(),
|
||||||
},
|
},
|
||||||
Range::from_located(arg),
|
Range::from_located(arg),
|
||||||
|
|
@ -175,7 +325,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
{
|
{
|
||||||
if checker.settings.rules.enabled(&Rule::MissingTypeKwargs) {
|
if checker.settings.rules.enabled(&Rule::MissingTypeKwargs) {
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingTypeKwargs {
|
MissingTypeKwargs {
|
||||||
name: arg.node.arg.to_string(),
|
name: arg.node.arg.to_string(),
|
||||||
},
|
},
|
||||||
Range::from_located(arg),
|
Range::from_located(arg),
|
||||||
|
|
@ -192,7 +342,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
if visibility::is_classmethod(checker, cast::decorator_list(stmt)) {
|
if visibility::is_classmethod(checker, cast::decorator_list(stmt)) {
|
||||||
if checker.settings.rules.enabled(&Rule::MissingTypeCls) {
|
if checker.settings.rules.enabled(&Rule::MissingTypeCls) {
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingTypeCls {
|
MissingTypeCls {
|
||||||
name: arg.node.arg.to_string(),
|
name: arg.node.arg.to_string(),
|
||||||
},
|
},
|
||||||
Range::from_located(arg),
|
Range::from_located(arg),
|
||||||
|
|
@ -201,7 +351,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
} else {
|
} else {
|
||||||
if checker.settings.rules.enabled(&Rule::MissingTypeSelf) {
|
if checker.settings.rules.enabled(&Rule::MissingTypeSelf) {
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingTypeSelf {
|
MissingTypeSelf {
|
||||||
name: arg.node.arg.to_string(),
|
name: arg.node.arg.to_string(),
|
||||||
},
|
},
|
||||||
Range::from_located(arg),
|
Range::from_located(arg),
|
||||||
|
|
@ -237,7 +387,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
.enabled(&Rule::MissingReturnTypeClassMethod)
|
.enabled(&Rule::MissingReturnTypeClassMethod)
|
||||||
{
|
{
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingReturnTypeClassMethod {
|
MissingReturnTypeClassMethod {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
},
|
},
|
||||||
helpers::identifier_range(stmt, checker.locator),
|
helpers::identifier_range(stmt, checker.locator),
|
||||||
|
|
@ -252,7 +402,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
.enabled(&Rule::MissingReturnTypeStaticMethod)
|
.enabled(&Rule::MissingReturnTypeStaticMethod)
|
||||||
{
|
{
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingReturnTypeStaticMethod {
|
MissingReturnTypeStaticMethod {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
},
|
},
|
||||||
helpers::identifier_range(stmt, checker.locator),
|
helpers::identifier_range(stmt, checker.locator),
|
||||||
|
|
@ -270,7 +420,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
&& has_any_typed_arg)
|
&& has_any_typed_arg)
|
||||||
{
|
{
|
||||||
let mut diagnostic = Diagnostic::new(
|
let mut diagnostic = Diagnostic::new(
|
||||||
violations::MissingReturnTypeSpecialMethod {
|
MissingReturnTypeSpecialMethod {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
},
|
},
|
||||||
helpers::identifier_range(stmt, checker.locator),
|
helpers::identifier_range(stmt, checker.locator),
|
||||||
|
|
@ -293,7 +443,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
.enabled(&Rule::MissingReturnTypeSpecialMethod)
|
.enabled(&Rule::MissingReturnTypeSpecialMethod)
|
||||||
{
|
{
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingReturnTypeSpecialMethod {
|
MissingReturnTypeSpecialMethod {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
},
|
},
|
||||||
helpers::identifier_range(stmt, checker.locator),
|
helpers::identifier_range(stmt, checker.locator),
|
||||||
|
|
@ -308,7 +458,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
.enabled(&Rule::MissingReturnTypePublicFunction)
|
.enabled(&Rule::MissingReturnTypePublicFunction)
|
||||||
{
|
{
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingReturnTypePublicFunction {
|
MissingReturnTypePublicFunction {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
},
|
},
|
||||||
helpers::identifier_range(stmt, checker.locator),
|
helpers::identifier_range(stmt, checker.locator),
|
||||||
|
|
@ -322,7 +472,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||||
.enabled(&Rule::MissingReturnTypePrivateFunction)
|
.enabled(&Rule::MissingReturnTypePrivateFunction)
|
||||||
{
|
{
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::MissingReturnTypePrivateFunction {
|
MissingReturnTypePrivateFunction {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
},
|
},
|
||||||
helpers::identifier_range(stmt, checker.locator),
|
helpers::identifier_range(stmt, checker.locator),
|
||||||
|
|
|
||||||
|
|
@ -106,156 +106,6 @@ impl AlwaysAutofixableViolation for PPrintFound {
|
||||||
"Remove `pprint`".to_string()
|
"Remove `pprint`".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// flake8-annotations
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingTypeFunctionArgument {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingTypeFunctionArgument {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingTypeFunctionArgument { name } = self;
|
|
||||||
format!("Missing type annotation for function argument `{name}`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingTypeArgs {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingTypeArgs {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingTypeArgs { name } = self;
|
|
||||||
format!("Missing type annotation for `*{name}`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingTypeKwargs {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingTypeKwargs {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingTypeKwargs { name } = self;
|
|
||||||
format!("Missing type annotation for `**{name}`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingTypeSelf {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingTypeSelf {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingTypeSelf { name } = self;
|
|
||||||
format!("Missing type annotation for `{name}` in method")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingTypeCls {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingTypeCls {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingTypeCls { name } = self;
|
|
||||||
format!("Missing type annotation for `{name}` in classmethod")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingReturnTypePublicFunction {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingReturnTypePublicFunction {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingReturnTypePublicFunction { name } = self;
|
|
||||||
format!("Missing return type annotation for public function `{name}`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingReturnTypePrivateFunction {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingReturnTypePrivateFunction {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingReturnTypePrivateFunction { name } = self;
|
|
||||||
format!("Missing return type annotation for private function `{name}`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingReturnTypeSpecialMethod {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl AlwaysAutofixableViolation for MissingReturnTypeSpecialMethod {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingReturnTypeSpecialMethod { name } = self;
|
|
||||||
format!("Missing return type annotation for special method `{name}`")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn autofix_title(&self) -> String {
|
|
||||||
"Add `None` return type".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingReturnTypeStaticMethod {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingReturnTypeStaticMethod {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingReturnTypeStaticMethod { name } = self;
|
|
||||||
format!("Missing return type annotation for staticmethod `{name}`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct MissingReturnTypeClassMethod {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for MissingReturnTypeClassMethod {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let MissingReturnTypeClassMethod { name } = self;
|
|
||||||
format!("Missing return type annotation for classmethod `{name}`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define_violation!(
|
|
||||||
pub struct DynamicallyTypedExpression {
|
|
||||||
pub name: String,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
impl Violation for DynamicallyTypedExpression {
|
|
||||||
#[derive_message_formats]
|
|
||||||
fn message(&self) -> String {
|
|
||||||
let DynamicallyTypedExpression { name } = self;
|
|
||||||
format!("Dynamically typed expressions (typing.Any) are disallowed in `{name}`")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// flake8-2020
|
// flake8-2020
|
||||||
|
|
||||||
define_violation!(
|
define_violation!(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue