[pep8_naming] Avoid false positives on standard library functions with uppercase names (N802)#18907
Conversation
…http.server.BaseHTTPRequestHandler from triggering N802
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| N802 | 8 | 0 | 8 | 0 | 0 |
| RUF100 | 3 | 3 | 0 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+3 -8 violations, +0 -0 fixes in 4 projects; 51 projects unchanged)
apache/airflow (+0 -6 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- airflow-core/src/airflow/utils/scheduler_health.py:36:9: N802 Function name `do_GET` should be lowercase - dev/breeze/src/airflow_breeze/commands/release_management_commands.py:3387:17: N802 Function name `visit_FunctionDef` should be lowercase - scripts/ci/pre_commit/check_deferrable_default.py:45:9: N802 Function name `visit_FunctionDef` should be lowercase - scripts/in_container/run_template_fields_check.py:52:9: N802 Function name `visit_FunctionDef` should be lowercase - scripts/in_container/run_template_fields_check.py:57:9: N802 Function name `visit_Assign` should be lowercase - scripts/in_container/run_template_fields_check.py:66:9: N802 Function name `visit_AnnAssign` should be lowercase
bokeh/bokeh (+0 -1 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- tests/support/plugins/file_server.py:59:9: N802 Function name `do_GET` should be lowercase
langchain-ai/langchain (+2 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
+ libs/cli/langchain_cli/namespaces/migrate/generate/utils.py:23:48: RUF100 [*] Unused `noqa` directive (unused: `N802`) + libs/cli/langchain_cli/namespaces/migrate/generate/utils.py:42:50: RUF100 [*] Unused `noqa` directive (unused: `N802`)
latchbio/latch (+1 -1 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
- src/latch_cli/auth/oauth2.py:89:17: N802 Function name `do_GET` should be lowercase + src/latch_cli/centromere/ast_parsing.py:32:58: RUF100 [*] Unused `noqa` directive (unused: `N802`)
Changes by rule (2 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| N802 | 8 | 0 | 8 | 0 | 0 |
| RUF100 | 3 | 3 | 0 | 0 | 0 |
|
I don't think the special handling for Special casing the http handler seems fine, while unfortunate |
|
|
|
@MichaReiser is this an acceptable solution? |
ntBre
left a comment
There was a problem hiding this comment.
This looks reasonable to me if it's okay with @MichaReiser. I just had a few small suggestions.
Before 3.12 I think users could still get @override from typing_extensions, but I'm not sure if that would be a better approach.
crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs
Outdated
Show resolved
Hide resolved
* dcreager/merge-arguments: (223 commits) fix docs Combine CallArguments and CallArgumentTypes [ty] Sync vendored typeshed stubs (#19334) [`refurb`] Make example error out-of-the-box (`FURB122`) (#19297) [refurb] Make example error out-of-the-box (FURB177) (#19309) [ty] ignore errors when reformatting codemodded typeshed (#19332) [ty] Provide docstrings for stdlib APIs when hovering over them in an IDE (#19311) [ty] Add virtual files to the only project database (#19322) Add t-string fixtures for rules that do not need to be modified (#19146) [ty] Remove `FileLookupError` (#19323) [ty] Fix handling of metaclasses in `object.<CURSOR>` completions [ty] Use an interval map for scopes by expression (#19025) [ty] List all `enum` members (#19283) [ty] Handle configuration errors in LSP more gracefully (#19262) [ty] Use python version and path from Python extension (#19012) [`pep8_naming`] Avoid false positives on standard library functions with uppercase names (`N802`) (#18907) Update Rust crate toml to 0.9.0 (#19320) [ty] Fix server version (#19284) Update NPM Development dependencies (#19319) Update taiki-e/install-action action to v2.56.13 (#19317) ...
Summary
This change prevents the
visit_*methods of ast.NodeVisitor/NodeTransformer and thedo_*methods of http.server.BaseHTTPRequestHandler from triggering N802. See #9400 for more information.In
Lib/ast.py:Example usage
Previously, this would trigger a N802 violation, even though the uppercase name is the intended way of using those subclasses.
Test Plan
I added tests to
pep8_naming/N802.py.