From 1a3d2ead41f62bf49ac90a2ba8f9b52eee4c8e4f Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 20 Nov 2022 17:55:57 -0500 Subject: [PATCH] Support PEP 562 (#841) --- resources/test/fixtures/N807.py | 21 +++++++++++++++++++ src/pep8_naming/checks.rs | 5 +++++ .../ruff__linter__tests__N807_N807.py.snap | 8 +++++++ 3 files changed, 34 insertions(+) diff --git a/resources/test/fixtures/N807.py b/resources/test/fixtures/N807.py index f9513ce71c..42f5152403 100644 --- a/resources/test/fixtures/N807.py +++ b/resources/test/fixtures/N807.py @@ -10,6 +10,27 @@ def good__(): pass +def nested(): + def __bad__(): + pass + + def __good(): + pass + + def good__(): + pass + + class Class: def __good__(self): pass + + +# https://peps.python.org/pep-0562/ +def __getattr__(name): + pass + + +# https://peps.python.org/pep-0562/ +def __dir__(): + pass diff --git a/src/pep8_naming/checks.rs b/src/pep8_naming/checks.rs index 048574ebe6..f819615d73 100644 --- a/src/pep8_naming/checks.rs +++ b/src/pep8_naming/checks.rs @@ -132,6 +132,11 @@ pub fn dunder_function_name(scope: &Scope, stmt: &Stmt, name: &str) -> Option