From 0c81b398aba5d77ff9293f348e2ce28282ff7d54 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Thu, 6 Feb 2025 21:58:08 +0000 Subject: [PATCH] [BE][Ez]: Enable some additional pylint ruff warnings (#146609) Some additional code hardening with some pylint warnings in ruff that usually indicate bugs. All code currently conforms nicely to them, but this will ensure these errors can be detected statically before running / creating tests. The follow rules: * Ban walrus operators where they would have no effect over regular assignment; making intention more clear. * Statically check for the common error of forgetting to put parens after the `super` call, which will cause an attribute error * Ban bad string literal args to builtins `open` Pull Request resolved: https://github.com/pytorch/pytorch/pull/146609 Approved by: https://github.com/aorenste --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index bf5269cb449..602e54daf65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,9 +122,12 @@ select = [ "PLR1722", # use sys exit "PLR1736", # unnecessary list index "PLW0129", # assert on string literal + "PLW0131", # named expr without context "PLW0133", # useless exception statement + "PLW0245", # super without brackets "PLW0406", # import self "PLW0711", # binary op exception + "PLW1501", # bad open mode "PLW1509", # preexec_fn not safe with threads "PLW2101", # useless lock statement "PLW3301", # nested min max