Skip to content

Commit 4f32b32

Browse files
authored
ci/cd: add pylint to CI (#811)
* add a workflow to run pylint * add a section to `pyproject.toml` that blacklists all rules which would trigger given the current code * pin a version of pylint in `requirements.txt` for reproducability In a followup PR I will remove some rules from the blacklist and fix some bugs.
1 parent 093e959 commit 4f32b32

3 files changed

Lines changed: 154 additions & 0 deletions

File tree

.github/workflows/pylint.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Pylint Check
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.py'
7+
- 'requirements.txt'
8+
- 'pyproject.toml'
9+
pull_request:
10+
paths:
11+
- '**.py'
12+
- 'requirements.txt'
13+
- 'pyproject.toml'
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: '3.12'
27+
28+
- name: Install pylint (version from requirements.txt)
29+
run: |
30+
PYLINT_VERSION=$(grep '^pylint' requirements.txt)
31+
if [ -z "$PYLINT_VERSION" ]; then
32+
echo "No pylint version found in requirements.txt"
33+
exit 1
34+
fi
35+
# only install pylint to avoid dependency problems on CPU
36+
pip install "$PYLINT_VERSION"
37+
38+
- name: Run pylint
39+
run: |
40+
pylint --recursive=y --rcfile=pyproject.toml ./

pyproject.toml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,116 @@ verl = [
4646
"version/*",
4747
"trainer/config/*.yaml"
4848
]
49+
50+
51+
[tool.pylint.message_control]
52+
disable = [
53+
"abstract-method",
54+
"anomalous-backslash-in-string",
55+
"arguments-differ",
56+
"arguments-renamed",
57+
"assignment-from-none",
58+
"attribute-defined-outside-init",
59+
"bad-str-strip-call",
60+
"bare-except",
61+
"broad-exception-caught",
62+
"broad-exception-raised",
63+
"cell-var-from-loop",
64+
"chained-comparison",
65+
"consider-iterating-dictionary",
66+
"consider-using-enumerate",
67+
"consider-using-f-string",
68+
"consider-using-from-import",
69+
"consider-using-generator",
70+
"consider-using-in",
71+
"consider-using-max-builtin",
72+
"consider-using-set-comprehension",
73+
"consider-using-sys-exit",
74+
"consider-using-with",
75+
"cyclic-import",
76+
"dangerous-default-value",
77+
"duplicate-code",
78+
"eval-used",
79+
"expression-not-assigned",
80+
"f-string-without-interpolation",
81+
"fixme",
82+
"function-redefined",
83+
"global-statement",
84+
"global-variable-not-assigned",
85+
"import-error",
86+
"import-outside-toplevel",
87+
"import-self",
88+
"inconsistent-return-statements",
89+
"invalid-character-zero-width-space",
90+
"invalid-name",
91+
"line-too-long",
92+
"logging-fstring-interpolation",
93+
"logging-not-lazy",
94+
"missing-class-docstring",
95+
"missing-final-newline",
96+
"missing-function-docstring",
97+
"missing-module-docstring",
98+
"multiple-imports",
99+
"no-else-continue",
100+
"no-else-raise",
101+
"no-else-return",
102+
"no-member",
103+
"no-self-argument",
104+
"no-value-for-parameter",
105+
"not-an-iterable",
106+
"not-callable",
107+
"notimplemented-raised",
108+
"pointless-exception-statement",
109+
"pointless-string-statement",
110+
"pointless-statement",
111+
"possibly-used-before-assignment",
112+
"protected-access",
113+
"raise-missing-from",
114+
"raising-format-tuple",
115+
"redefined-argument-from-local",
116+
"redefined-builtin",
117+
"redefined-outer-name",
118+
"redundant-u-string-prefix",
119+
"reimported",
120+
"simplifiable-if-expression",
121+
"simplifiable-if-statement",
122+
"singleton-comparison",
123+
"super-init-not-called",
124+
"superfluous-parens",
125+
"too-few-public-methods",
126+
"too-many-arguments",
127+
"too-many-boolean-expressions",
128+
"too-many-branches",
129+
"too-many-instance-attributes",
130+
"too-many-lines",
131+
"too-many-locals",
132+
"too-many-positional-arguments",
133+
"too-many-return-statements",
134+
"too-many-statements",
135+
"trailing-newlines",
136+
"trailing-newlines",
137+
"trailing-whitespace",
138+
"unbalanced-tuple-unpacking",
139+
"undefined-loop-variable",
140+
"undefined-variable",
141+
"ungrouped-imports",
142+
"unidiomatic-typecheck",
143+
"unnecessary-comprehension",
144+
"unnecessary-lambda",
145+
"unnecessary-lambda-assignment",
146+
"unnecessary-pass",
147+
"unspecified-encoding",
148+
"unused-argument",
149+
"unused-import",
150+
"unused-variable",
151+
"unused-wildcard-import",
152+
"use-a-generator",
153+
"use-dict-literal",
154+
"used-before-assignment",
155+
"useless-object-inheritance",
156+
"useless-parent-delegation",
157+
"useless-return",
158+
"wildcard-import",
159+
"wrong-import-order",
160+
"wrong-import-position",
161+
]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ peft
1212
pyarrow>=15.0.0
1313
pybind11
1414
pylatexenc
15+
pylint==3.3.6
1516
ray[default]
1617
tensordict<=0.6.2
1718
torchdata

0 commit comments

Comments
 (0)