mirror of https://github.com/astral-sh/ruff
Fix --ignore for ANN101 and ANN102 (#637)
This commit is contained in:
parent
dd20b23576
commit
8fc435bad9
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Type
|
||||
|
||||
# Error
|
||||
def foo(a, b):
|
||||
pass
|
||||
|
|
@ -31,3 +33,23 @@ def foo(a: int, b: int) -> int:
|
|||
# OK
|
||||
def foo() -> int:
|
||||
pass
|
||||
|
||||
|
||||
class Foo:
|
||||
# OK
|
||||
def foo(self: "Foo", a: int, b: int) -> int:
|
||||
pass
|
||||
|
||||
# ANN101
|
||||
def foo(self, a: int, b: int) -> int:
|
||||
pass
|
||||
|
||||
# OK
|
||||
@classmethod
|
||||
def foo(cls: Type["Foo"], a: int, b: int) -> int:
|
||||
pass
|
||||
|
||||
# ANN102
|
||||
@classmethod
|
||||
def foo(cls, a: int, b: int) -> int:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -241,14 +241,14 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
|||
if let Some(arg) = args.args.first() {
|
||||
if arg.node.annotation.is_none() {
|
||||
if visibility::is_classmethod(stmt) {
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN101) {
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN102) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingTypeCls,
|
||||
Range::from_located(arg),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN102) {
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN101) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingTypeSelf,
|
||||
Range::from_located(arg),
|
||||
|
|
|
|||
|
|
@ -4,66 +4,82 @@ expression: checks
|
|||
---
|
||||
- kind: MissingReturnTypePublicFunction
|
||||
location:
|
||||
row: 2
|
||||
row: 4
|
||||
column: 0
|
||||
end_location:
|
||||
row: 7
|
||||
row: 9
|
||||
column: 0
|
||||
fix: ~
|
||||
- kind: MissingTypeFunctionArgument
|
||||
location:
|
||||
row: 2
|
||||
row: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 2
|
||||
row: 4
|
||||
column: 9
|
||||
fix: ~
|
||||
- kind: MissingTypeFunctionArgument
|
||||
location:
|
||||
row: 2
|
||||
row: 4
|
||||
column: 11
|
||||
end_location:
|
||||
row: 2
|
||||
row: 4
|
||||
column: 12
|
||||
fix: ~
|
||||
- kind: MissingReturnTypePublicFunction
|
||||
location:
|
||||
row: 7
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 12
|
||||
row: 14
|
||||
column: 0
|
||||
fix: ~
|
||||
- kind: MissingTypeFunctionArgument
|
||||
location:
|
||||
row: 7
|
||||
row: 9
|
||||
column: 16
|
||||
end_location:
|
||||
row: 7
|
||||
row: 9
|
||||
column: 17
|
||||
fix: ~
|
||||
- kind: MissingTypeFunctionArgument
|
||||
location:
|
||||
row: 12
|
||||
row: 14
|
||||
column: 16
|
||||
end_location:
|
||||
row: 12
|
||||
row: 14
|
||||
column: 17
|
||||
fix: ~
|
||||
- kind: MissingReturnTypePublicFunction
|
||||
location:
|
||||
row: 17
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 22
|
||||
row: 24
|
||||
column: 0
|
||||
fix: ~
|
||||
- kind: MissingReturnTypePublicFunction
|
||||
location:
|
||||
row: 22
|
||||
row: 24
|
||||
column: 0
|
||||
end_location:
|
||||
row: 27
|
||||
row: 29
|
||||
column: 0
|
||||
fix: ~
|
||||
- kind: MissingTypeSelf
|
||||
location:
|
||||
row: 44
|
||||
column: 12
|
||||
end_location:
|
||||
row: 44
|
||||
column: 16
|
||||
fix: ~
|
||||
- kind: MissingTypeCls
|
||||
location:
|
||||
row: 54
|
||||
column: 12
|
||||
end_location:
|
||||
row: 54
|
||||
column: 15
|
||||
fix: ~
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue