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
|
# Error
|
||||||
def foo(a, b):
|
def foo(a, b):
|
||||||
pass
|
pass
|
||||||
|
|
@ -31,3 +33,23 @@ def foo(a: int, b: int) -> int:
|
||||||
# OK
|
# OK
|
||||||
def foo() -> int:
|
def foo() -> int:
|
||||||
pass
|
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 let Some(arg) = args.args.first() {
|
||||||
if arg.node.annotation.is_none() {
|
if arg.node.annotation.is_none() {
|
||||||
if visibility::is_classmethod(stmt) {
|
if visibility::is_classmethod(stmt) {
|
||||||
if checker.settings.enabled.contains(&CheckCode::ANN101) {
|
if checker.settings.enabled.contains(&CheckCode::ANN102) {
|
||||||
checker.add_check(Check::new(
|
checker.add_check(Check::new(
|
||||||
CheckKind::MissingTypeCls,
|
CheckKind::MissingTypeCls,
|
||||||
Range::from_located(arg),
|
Range::from_located(arg),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if checker.settings.enabled.contains(&CheckCode::ANN102) {
|
if checker.settings.enabled.contains(&CheckCode::ANN101) {
|
||||||
checker.add_check(Check::new(
|
checker.add_check(Check::new(
|
||||||
CheckKind::MissingTypeSelf,
|
CheckKind::MissingTypeSelf,
|
||||||
Range::from_located(arg),
|
Range::from_located(arg),
|
||||||
|
|
|
||||||
|
|
@ -4,66 +4,82 @@ expression: checks
|
||||||
---
|
---
|
||||||
- kind: MissingReturnTypePublicFunction
|
- kind: MissingReturnTypePublicFunction
|
||||||
location:
|
location:
|
||||||
row: 2
|
row: 4
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 7
|
row: 9
|
||||||
column: 0
|
column: 0
|
||||||
fix: ~
|
fix: ~
|
||||||
- kind: MissingTypeFunctionArgument
|
- kind: MissingTypeFunctionArgument
|
||||||
location:
|
location:
|
||||||
row: 2
|
row: 4
|
||||||
column: 8
|
column: 8
|
||||||
end_location:
|
end_location:
|
||||||
row: 2
|
row: 4
|
||||||
column: 9
|
column: 9
|
||||||
fix: ~
|
fix: ~
|
||||||
- kind: MissingTypeFunctionArgument
|
- kind: MissingTypeFunctionArgument
|
||||||
location:
|
location:
|
||||||
row: 2
|
row: 4
|
||||||
column: 11
|
column: 11
|
||||||
end_location:
|
end_location:
|
||||||
row: 2
|
row: 4
|
||||||
column: 12
|
column: 12
|
||||||
fix: ~
|
fix: ~
|
||||||
- kind: MissingReturnTypePublicFunction
|
- kind: MissingReturnTypePublicFunction
|
||||||
location:
|
location:
|
||||||
row: 7
|
row: 9
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 12
|
row: 14
|
||||||
column: 0
|
column: 0
|
||||||
fix: ~
|
fix: ~
|
||||||
- kind: MissingTypeFunctionArgument
|
- kind: MissingTypeFunctionArgument
|
||||||
location:
|
location:
|
||||||
row: 7
|
row: 9
|
||||||
column: 16
|
column: 16
|
||||||
end_location:
|
end_location:
|
||||||
row: 7
|
row: 9
|
||||||
column: 17
|
column: 17
|
||||||
fix: ~
|
fix: ~
|
||||||
- kind: MissingTypeFunctionArgument
|
- kind: MissingTypeFunctionArgument
|
||||||
location:
|
location:
|
||||||
row: 12
|
row: 14
|
||||||
column: 16
|
column: 16
|
||||||
end_location:
|
end_location:
|
||||||
row: 12
|
row: 14
|
||||||
column: 17
|
column: 17
|
||||||
fix: ~
|
fix: ~
|
||||||
- kind: MissingReturnTypePublicFunction
|
- kind: MissingReturnTypePublicFunction
|
||||||
location:
|
location:
|
||||||
row: 17
|
row: 19
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 22
|
row: 24
|
||||||
column: 0
|
column: 0
|
||||||
fix: ~
|
fix: ~
|
||||||
- kind: MissingReturnTypePublicFunction
|
- kind: MissingReturnTypePublicFunction
|
||||||
location:
|
location:
|
||||||
row: 22
|
row: 24
|
||||||
column: 0
|
column: 0
|
||||||
end_location:
|
end_location:
|
||||||
row: 27
|
row: 29
|
||||||
column: 0
|
column: 0
|
||||||
fix: ~
|
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