mirror of https://github.com/astral-sh/ruff
Accommodate pos-only arguments when checking self name (#2626)
This commit is contained in:
parent
2b4ce78830
commit
9fa98ed90b
|
|
@ -51,3 +51,11 @@ class MetaClass(ABCMeta):
|
||||||
|
|
||||||
def func(x):
|
def func(x):
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
|
class PosOnlyClass:
|
||||||
|
def good_method_pos_only(self, blah, /, something: str):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def bad_method_pos_only(this, blah, /, self, something: str):
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ pub fn invalid_first_argument_name_for_method(
|
||||||
) {
|
) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let arg = args.args.first()?;
|
let arg = args.posonlyargs.first().or_else(|| args.args.first())?;
|
||||||
if arg.node.arg == "self" {
|
if arg.node.arg == "self" {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/rules/pep8_naming/mod.rs
|
source: crates/ruff/src/rules/pep8_naming/mod.rs
|
||||||
expression: diagnostics
|
expression: diagnostics
|
||||||
---
|
---
|
||||||
- kind:
|
- kind:
|
||||||
|
|
@ -42,4 +42,14 @@ expression: diagnostics
|
||||||
column: 17
|
column: 17
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
InvalidFirstArgumentNameForMethod: ~
|
||||||
|
location:
|
||||||
|
row: 60
|
||||||
|
column: 28
|
||||||
|
end_location:
|
||||||
|
row: 60
|
||||||
|
column: 32
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue