Skip to content

Commit d1ecf63

Browse files
authored
STYLE ignore no-else-* checks, + assorted cleanups (#49750)
* ignore no-else-*, comment some checks as intentionally turned off, share env for two hooks * add redefined-outer-name check, but turn off in remaining files * keep redefined-outer-name to manual stage * update exclude list * reword * fixup after merge * fixup again Co-authored-by: MarcoGorelli <>
1 parent 474b3db commit d1ecf63

File tree

3 files changed

+56
-30
lines changed

3 files changed

+56
-30
lines changed

.github/workflows/code-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jobs:
3737
- name: Run pre-commit
3838
uses: pre-commit/[email protected]
3939

40-
typing_and_docstring_validation:
41-
name: Docstring and typing validation
40+
docstring_typing_pylint:
41+
name: Docstring validation, typing, and pylint
4242
runs-on: ubuntu-latest
4343
defaults:
4444
run:

.pre-commit-config.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ repos:
6464
hooks:
6565
- id: pylint
6666
stages: [manual]
67+
- repo: https://github.com/pycqa/pylint
68+
rev: v2.15.5
69+
hooks:
70+
- id: pylint
71+
alias: redefined-outer-name
72+
name: Redefining name from outer scope
73+
files: ^pandas/
74+
exclude: |
75+
(?x)
76+
^pandas/tests # keep excluded
77+
|/_testing/ # keep excluded
78+
|^pandas/util/_test_decorators\.py # keep excluded
79+
|^pandas/_version\.py # keep excluded
80+
|^pandas/conftest\.py # keep excluded
81+
|^pandas/core/tools/datetimes\.py
82+
|^pandas/io/formats/format\.py
83+
|^pandas/core/generic\.py
84+
args: [--disable=all, --enable=redefined-outer-name]
85+
stages: [manual]
6786
- repo: https://github.com/PyCQA/isort
6887
rev: 5.10.1
6988
hooks:
@@ -201,7 +220,7 @@ repos:
201220
entry: python scripts/sync_flake8_versions.py
202221
files: ^(\.pre-commit-config\.yaml|environment\.yml)$
203222
pass_filenames: false
204-
additional_dependencies: [pyyaml]
223+
additional_dependencies: [pyyaml, toml]
205224
- id: title-capitalization
206225
name: Validate correct capitalization among titles in documentation
207226
entry: python scripts/validate_rst_title_capitalization.py

pyproject.toml

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,61 +58,70 @@ exclude = '''
5858
[tool.pylint.messages_control]
5959
max-line-length = 88
6060
disable = [
61-
"abstract-class-instantiated",
61+
# intentionally turned off
6262
"c-extension-no-member",
63+
"comparison-with-itself",
6364
"import-error",
65+
"import-outside-toplevel",
66+
"invalid-name",
6467
"invalid-unary-operand-type",
68+
"line-too-long",
69+
"no-else-continue",
70+
"no-else-raise",
71+
"no-else-return",
6572
"no-member",
6673
"no-name-in-module",
67-
"no-value-for-parameter",
6874
"not-an-iterable",
75+
"pointless-statement",
6976
"redundant-keyword-arg",
77+
"singleton-comparison",
78+
"too-many-ancestors",
79+
"too-many-arguments",
80+
"too-many-boolean-expressions",
81+
"too-many-branches",
7082
"too-many-function-args",
71-
"undefined-variable",
83+
"too-many-instance-attributes",
84+
"too-many-locals",
85+
"too-many-nested-blocks",
86+
"too-many-public-methods",
87+
"too-many-return-statements",
88+
"too-many-statements",
7289
"unexpected-keyword-arg",
73-
"unpacking-non-sequence",
90+
"ungrouped-imports",
7491
"unsubscriptable-object",
7592
"unsupported-assignment-operation",
7693
"unsupported-membership-test",
94+
"unused-import",
95+
"use-implicit-booleaness-not-comparison",
96+
"use-implicit-booleaness-not-len",
97+
"wrong-import-order",
98+
"wrong-import-order",
99+
"wrong-import-position",
100+
101+
# misc
102+
"abstract-class-instantiated",
103+
"redundant-keyword-arg",
104+
"no-value-for-parameter",
105+
"undefined-variable",
106+
"unpacking-non-sequence",
77107

78108
# pylint type "C": convention, for programming standard violation
79-
"import-outside-toplevel",
80-
"invalid-name",
81-
"line-too-long",
82109
"missing-class-docstring",
83110
"missing-function-docstring",
84111
"missing-module-docstring",
85-
"singleton-comparison",
86112
"too-many-lines",
87-
"ungrouped-imports",
88113
"unidiomatic-typecheck",
89114
"unnecessary-dunder-call",
90115
"unnecessary-lambda-assignment",
91-
"use-implicit-booleaness-not-comparison",
92-
"use-implicit-booleaness-not-len",
93-
"wrong-import-order",
94-
"wrong-import-position",
95116

96117
# pylint type "R": refactor, for bad code smell
97-
"comparison-with-itself",
98118
"consider-using-ternary",
99119
"consider-using-with",
100120
"cyclic-import",
101121
"duplicate-code",
102122
"inconsistent-return-statements",
103-
"no-else-return",
104123
"redefined-argument-from-local",
105124
"too-few-public-methods",
106-
"too-many-ancestors",
107-
"too-many-arguments",
108-
"too-many-boolean-expressions",
109-
"too-many-branches",
110-
"too-many-instance-attributes",
111-
"too-many-locals",
112-
"too-many-nested-blocks",
113-
"too-many-public-methods",
114-
"too-many-return-statements",
115-
"too-many-statements",
116125
"unnecessary-list-index-lookup",
117126

118127
# pylint type "W": warning, for python specific problems
@@ -132,7 +141,6 @@ disable = [
132141
"invalid-overridden-method",
133142
"keyword-arg-before-vararg",
134143
"overridden-final-method",
135-
"pointless-statement",
136144
"pointless-string-statement",
137145
"possibly-unused-variable",
138146
"protected-access",
@@ -148,7 +156,6 @@ disable = [
148156
"unnecessary-lambda",
149157
"unspecified-encoding",
150158
"unused-argument",
151-
"unused-import",
152159
"unused-variable",
153160
"using-constant-test",
154161
"useless-parent-delegation"

0 commit comments

Comments
 (0)