From e975b7b24d1f0da3c34a69ac460c735a5c3eefb7 Mon Sep 17 00:00:00 2001 From: Brian Schubert Date: Mon, 11 Nov 2024 11:11:20 -0500 Subject: [PATCH] Enable pep8-naming rules in ruff lint config --- mypy/nodes.py | 2 +- mypy/test/teststubgen.py | 2 +- mypyc/lib-rt/setup.py | 2 +- mypyc/test/test_emitfunc.py | 2 +- pyproject.toml | 7 +++++++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mypy/nodes.py b/mypy/nodes.py index dabfb463cc95..56c61ce26d63 100644 --- a/mypy/nodes.py +++ b/mypy/nodes.py @@ -1727,7 +1727,7 @@ def accept(self, visitor: ExpressionVisitor[T]) -> T: return visitor.visit_str_expr(self) -def is_StrExpr_list(seq: list[Expression]) -> TypeGuard[list[StrExpr]]: +def is_StrExpr_list(seq: list[Expression]) -> TypeGuard[list[StrExpr]]: # noqa: N802 return all(isinstance(item, StrExpr) for item in seq) diff --git a/mypy/test/teststubgen.py b/mypy/test/teststubgen.py index 46e805d9ca82..dffa1aa80c5d 100644 --- a/mypy/test/teststubgen.py +++ b/mypy/test/teststubgen.py @@ -987,7 +987,7 @@ def test(cls, arg0: str) -> None: def test_generate_c_type_classmethod_with_overloads(self) -> None: class TestClass: @classmethod - def test(self, arg0: str) -> None: + def test(cls, arg0: str) -> None: """ test(cls, arg0: str) test(cls, arg0: int) diff --git a/mypyc/lib-rt/setup.py b/mypyc/lib-rt/setup.py index 66b130581cb3..1faacc8fc136 100644 --- a/mypyc/lib-rt/setup.py +++ b/mypyc/lib-rt/setup.py @@ -21,7 +21,7 @@ compile_args = ["--std=c++11"] -class build_ext_custom(build_ext): +class build_ext_custom(build_ext): # noqa: N801 def get_library_names(self): return ["gtest"] diff --git a/mypyc/test/test_emitfunc.py b/mypyc/test/test_emitfunc.py index 317427afac5a..273ba409fac2 100644 --- a/mypyc/test/test_emitfunc.py +++ b/mypyc/test/test_emitfunc.py @@ -134,7 +134,7 @@ def test_integer(self) -> None: def test_tuple_get(self) -> None: self.assert_emit(TupleGet(self.t, 1, 0), "cpy_r_r0 = cpy_r_t.f1;") - def test_load_None(self) -> None: + def test_load_None(self) -> None: # noqa: N802 self.assert_emit( LoadAddress(none_object_op.type, none_object_op.src, 0), "cpy_r_r0 = (PyObject *)&_Py_NoneStruct;", diff --git a/pyproject.toml b/pyproject.toml index 06f83506ae4f..e452c7a43b1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ select = [ "W", # pycodestyle (warning) "B", # flake8-bugbear "I", # isort + "N", # pep8-naming "RUF100", # Unused noqa comments "PGH004", # blanket noqa comments "UP", # pyupgrade @@ -68,6 +69,8 @@ ignore = [ "E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks "E731", # Do not assign a `lambda` expression, use a `def` "E741", # Ambiguous variable name + "N818", # Exception should be named with an Error suffix + "N806", # UPPER_CASE used for constant local variables "UP031", # Use format specifiers instead of percent format "UP032", # 'f-string always preferable to format' is controversial "C416", # There are a few cases where it's nice to have names for the dict items @@ -81,6 +84,10 @@ unfixable = [ "UP036", # sometimes it's better to just noqa this ] +[tool.ruff.lint.per-file-ignores] +# Mixed case variable and function names. +"mypy/fastparse.py" = ["N802", "N816"] + [tool.ruff.lint.isort] combine-as-imports = true extra-standard-library = ["typing_extensions"]