mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
[pep8-naming
] Fix N802
false positives for CGIHTTPRequestHandler
and SimpleHTTPRequestHandler
(#19432)
## Summary Fixes #19422
This commit is contained in:
parent
bb3a05f92b
commit
ba629fe262
3 changed files with 48 additions and 2 deletions
|
@ -84,3 +84,25 @@ class MyRequestHandler(BaseHTTPRequestHandler):
|
||||||
def dont_GET(self):
|
def dont_GET(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
from http.server import CGIHTTPRequestHandler
|
||||||
|
|
||||||
|
|
||||||
|
class MyCGIRequestHandler(CGIHTTPRequestHandler):
|
||||||
|
def do_OPTIONS(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def dont_OPTIONS(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
from http.server import SimpleHTTPRequestHandler
|
||||||
|
|
||||||
|
|
||||||
|
class MySimpleRequestHandler(SimpleHTTPRequestHandler):
|
||||||
|
def do_OPTIONS(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def dont_OPTIONS(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ pub(crate) fn invalid_function_name(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore the do_* methods of the http.server.BaseHTTPRequestHandler class
|
// Ignore the do_* methods of the http.server.BaseHTTPRequestHandler class and its subclasses
|
||||||
if name.starts_with("do_")
|
if name.starts_with("do_")
|
||||||
&& parent_class.is_some_and(|class| {
|
&& parent_class.is_some_and(|class| {
|
||||||
any_base_class(class, semantic, &mut |superclass| {
|
any_base_class(class, semantic, &mut |superclass| {
|
||||||
|
@ -108,7 +108,13 @@ pub(crate) fn invalid_function_name(
|
||||||
qualified.is_some_and(|name| {
|
qualified.is_some_and(|name| {
|
||||||
matches!(
|
matches!(
|
||||||
name.segments(),
|
name.segments(),
|
||||||
["http", "server", "BaseHTTPRequestHandler"]
|
[
|
||||||
|
"http",
|
||||||
|
"server",
|
||||||
|
"BaseHTTPRequestHandler"
|
||||||
|
| "CGIHTTPRequestHandler"
|
||||||
|
| "SimpleHTTPRequestHandler"
|
||||||
|
]
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -55,3 +55,21 @@ N802.py:84:9: N802 Function name `dont_GET` should be lowercase
|
||||||
| ^^^^^^^^ N802
|
| ^^^^^^^^ N802
|
||||||
85 | pass
|
85 | pass
|
||||||
|
|
|
|
||||||
|
|
||||||
|
N802.py:95:9: N802 Function name `dont_OPTIONS` should be lowercase
|
||||||
|
|
|
||||||
|
93 | pass
|
||||||
|
94 |
|
||||||
|
95 | def dont_OPTIONS(self):
|
||||||
|
| ^^^^^^^^^^^^ N802
|
||||||
|
96 | pass
|
||||||
|
|
|
||||||
|
|
||||||
|
N802.py:106:9: N802 Function name `dont_OPTIONS` should be lowercase
|
||||||
|
|
|
||||||
|
104 | pass
|
||||||
|
105 |
|
||||||
|
106 | def dont_OPTIONS(self):
|
||||||
|
| ^^^^^^^^^^^^ N802
|
||||||
|
107 | pass
|
||||||
|
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue