1
1
# Pylint Development Instructions
2
2
3
- Always follow these instructions first and fallback to additional search and context gathering only if the information in these instructions is incomplete or found to be in error.
3
+ Always follow these instructions first and fallback to additional search and context
4
+ gathering only if the information in these instructions is incomplete or found to be in
5
+ error.
4
6
5
7
## Development Environment Setup
6
8
7
9
### Basic Installation
10
+
8
11
Clone and set up pylint development environment:
12
+
9
13
- ` git clone https://github.com/pylint-dev/pylint ` -- clone repository
10
14
- ` cd pylint ` -- enter directory
11
15
- ` python3 --version ` -- verify Python 3.8+ is available (development requires 3.8+)
@@ -15,34 +19,47 @@ Clone and set up pylint development environment:
15
19
- ` pip install -e . ` -- install pylint in editable mode (~ 30-60 seconds)
16
20
17
21
### Optional Setup Steps
22
+
18
23
- ` pre-commit install ` -- enable pre-commit hooks for autoformatting
19
24
- ` pip install pre-commit ` -- install pre-commit separately if needed
20
25
21
26
### Astroid Development (if needed)
27
+
22
28
If working on astroid changes:
29
+
23
30
- ` git clone https://github.com/pylint-dev/astroid.git ` -- clone astroid
24
31
- ` pip install -e astroid/ ` -- install astroid in editable mode
25
32
- ` cd astroid/ && git switch my-astroid-dev-branch ` -- switch to development branch
26
33
27
34
## Running Tests
28
35
29
36
### Core Test Commands
30
- - ` pytest tests/test_functional.py -k test_functional ` -- run functional tests (~ 60 seconds, NEVER CANCEL, set timeout to 120+ seconds)
31
- - ` pytest tests/ ` -- run all tests (several minutes, NEVER CANCEL, set timeout to 300+ seconds)
37
+
38
+ - ` pytest tests/test_functional.py -k test_functional ` -- run functional tests (~ 60
39
+ seconds, NEVER CANCEL, set timeout to 120+ seconds)
40
+ - ` pytest tests/ ` -- run all tests (several minutes, NEVER CANCEL, set timeout to 300+
41
+ seconds)
32
42
- ` python3 -m pytest ` -- run tests with local python
33
43
- ` pytest tests/test_check_parallel.py -v ` -- quick test file (~ 2 seconds)
34
44
35
45
### Specific Test Types
36
- - ** Functional tests:** ` pytest "tests/test_functional.py::test_functional[missing_kwoa_py3]" ` -- single functional test (~ 1 second)
46
+
47
+ - ** Functional tests:**
48
+ ` pytest "tests/test_functional.py::test_functional[missing_kwoa_py3]" ` -- single
49
+ functional test (~ 1 second)
37
50
- ** Unit tests:** Located in ` /tests/ ` directory, test specific pylint functionality
38
- - ** Configuration tests:** In ` /tests/config/functional/ ` for testing configuration loading
39
- - ** Primer tests:** ` pytest -m primer_stdlib --primer-stdlib ` -- test on stdlib for crashes
51
+ - ** Configuration tests:** In ` /tests/config/functional/ ` for testing configuration
52
+ loading
53
+ - ** Primer tests:** ` pytest -m primer_stdlib --primer-stdlib ` -- test on stdlib for
54
+ crashes
40
55
41
56
### Test with Coverage
57
+
42
58
- ` pytest tests/message/ --cov=pylint.message ` -- run with coverage
43
59
- ` coverage html ` -- generate HTML coverage report
44
60
45
61
### Tox Usage (Optional)
62
+
46
63
- ` python -m tox ` -- run all tox environments
47
64
- ` python -m tox -epy313 ` -- run Python 3.13 suite only
48
65
- ` python -m tox -epylint ` -- run pylint on pylint's codebase
@@ -53,55 +70,77 @@ If working on astroid changes:
53
70
## Documentation
54
71
55
72
### Building Documentation
73
+
56
74
- ` make -C doc/ install-dependencies ` -- install doc dependencies (~ 10 seconds)
57
- - ` make -C doc/ html ` -- build documentation (~ 3 minutes, NEVER CANCEL, set timeout to 300+ seconds)
75
+ - ` make -C doc/ html ` -- build documentation (~ 3 minutes, NEVER CANCEL, set timeout to
76
+ 300+ seconds)
58
77
- ` make -C doc/ clean ` -- clean build files when starting from scratch
59
78
- ` tox -e docs ` -- alternative way to build docs
60
79
61
- ** Network dependency:** Documentation build requires internet access to fetch external inventories.
80
+ ** Network dependency:** Documentation build requires internet access to fetch external
81
+ inventories.
62
82
63
83
## Validation and Quality Checks
64
84
65
85
### Running Pylint on Code
86
+
66
87
- ` pylint --help ` -- verify pylint installation works
67
- - ` pylint --disable=all --enable=E,F pylint/ ` -- run pylint on itself for errors only (~ 20 seconds)
88
+ - ` pylint --disable=all --enable=E,F pylint/ ` -- run pylint on itself for errors only
89
+ (~ 20 seconds)
68
90
- ` pylint --rcfile=pylintrc --fail-on=I path/to/your/changes.py ` -- standard pylint run
69
- - ` pylint --disable=all --enable=E,F,W path/to/your/changes.py ` -- focus on errors and warnings
91
+ - ` pylint --disable=all --enable=E,F,W path/to/your/changes.py ` -- focus on errors and
92
+ warnings
70
93
71
94
### Pre-commit and Formatting
72
- - ` pre-commit run --all-files ` -- run all formatting checks (requires network for initial setup)
73
- - ** Network dependency:** pre-commit may fail in isolated environments due to hook downloads
95
+
96
+ - ` pre-commit run --all-files ` -- run all formatting checks (requires network for
97
+ initial setup)
98
+ - ** Network dependency:** pre-commit may fail in isolated environments due to hook
99
+ downloads
74
100
75
101
### Validation Test Scenarios
102
+
76
103
Always test your changes with these validation scenarios:
77
- - ` echo "def badFunction(): pass" > /tmp/test_sample.py && pylint --enable=C0103 /tmp/test_sample.py ` -- should find naming issues
104
+
105
+ - ` echo "def badFunction(): pass" > /tmp/test_sample.py && pylint --enable=C0103 /tmp/test_sample.py `
106
+ -- should find naming issues
78
107
- ` pylint --help ` and ` pylint --list-msgs | head -10 ` -- verify CLI functionality
79
108
- ` pylint --help-msg=C0103 ` -- should show invalid-name help
80
- - ` pylint --rcfile=pylintrc --fail-on=I pylint/__init__.py ` -- should get 10.00/10 rating
109
+ - ` pylint --rcfile=pylintrc --fail-on=I pylint/__init__.py ` -- should get 10.00/10
110
+ rating
81
111
82
112
## Writing Tests
83
113
84
114
### Functional Tests
85
- Located in ` /tests/functional/ ` , consists of ` .py ` test files with corresponding ` .txt ` expected output files:
86
- - Annotate lines where messages are expected: ` a, b, c = 1 # [unbalanced-tuple-unpacking] `
87
- - Multiple messages on same line: ` a, b, c = 1.test # [unbalanced-tuple-unpacking, no-member] `
115
+
116
+ Located in ` /tests/functional/ ` , consists of ` .py ` test files with corresponding ` .txt `
117
+ expected output files:
118
+
119
+ - Annotate lines where messages are expected:
120
+ ` a, b, c = 1 # [unbalanced-tuple-unpacking] `
121
+ - Multiple messages on same line:
122
+ ` a, b, c = 1.test # [unbalanced-tuple-unpacking, no-member] `
88
123
- Use offset syntax for special cases: ` # +1: [singleton-comparison] `
89
- - ** Run and update:** ` python tests/test_functional.py --update-functional-output -k "test_functional[test_name]" `
124
+ - ** Run and update:**
125
+ ` python tests/test_functional.py --update-functional-output -k "test_functional[test_name]" `
90
126
91
127
### Test File Organization
128
+
92
129
- ** New checkers:** Create ` new_checker_message.py ` in ` /tests/functional/n/ `
93
130
- ** Extensions:** Place in ` /tests/functional/ext/extension_name/ `
94
131
- ** Regression tests:** Place in ` /tests/r/regression/ ` with ` regression_ ` prefix
95
132
- ** Configuration tests:** Place in ` /tests/config/functional/ `
96
133
97
134
### Configuration Test Files
135
+
98
136
Create ` .result.json ` files with configuration differences from standard config:
137
+
99
138
``` json
100
139
{
101
- "functional_append" : {
102
- "disable" : [[" a-message-to-be-added" ]]
103
- },
104
- "jobs" : 10
140
+ "functional_append" : {
141
+ "disable" : [[" a-message-to-be-added" ]]
142
+ },
143
+ "jobs" : 10
105
144
}
106
145
```
107
146
@@ -135,21 +174,24 @@ script/ # Development utility scripts
135
174
```
136
175
137
176
### Key Files
177
+
138
178
- ` pyproject.toml ` -- Main configuration (dependencies, build, tools)
139
179
- ` tox.ini ` -- Multi-environment testing configuration
140
- - ` .pre-commit-config.yaml ` -- Code quality checks configuration
180
+ - ` .pre-commit-config.yaml ` -- Code quality checks configuration
141
181
- ` pylintrc ` -- Pylint's own configuration
142
182
- ` requirements_test_min.txt ` -- Minimal test dependencies
143
183
144
184
## Creating New Checkers
145
185
146
186
### Getting Started
187
+
147
188
- ` python script/get_unused_message_id_category.py ` -- get next available message ID
148
189
- Study existing checkers in ` pylint/checkers/ ` for patterns
149
190
- Read technical reference documentation in ` doc/development_guide/technical_reference/ `
150
191
- Use ` astroid.extract_node ` for AST manipulation
151
192
152
193
### Workflow
194
+
153
195
1 . Create checker class in appropriate ` pylint/checkers/ ` file
154
196
2 . Add functional tests in ` tests/functional/ `
155
197
3 . Search existing code for warning message to find where logic exists
@@ -158,17 +200,20 @@ script/ # Development utility scripts
158
200
## Pull Request Guidelines
159
201
160
202
### Before Submitting
203
+
161
204
- Use Python 3.8+ for development (required for latest AST parser and pre-commit hooks)
162
205
- Write comprehensive commit messages relating to tracker issues
163
206
- Keep changes small and separate consensual from opinionated changes
164
207
- Add news fragment: ` towncrier create <IssueNumber>.<type> `
165
208
166
209
### Documentation Changes
210
+
167
211
- Document non-trivial changes
168
212
- Generate docs with ` tox -e docs `
169
213
- Maintainers may label issues ` skip-news ` if no changelog needed
170
214
171
215
### Contribution Credits
216
+
172
217
- Add emails/names to ` script/.contributors_aliases.json ` if using multiple identities
173
218
174
219
## Critical Timing Information
@@ -183,9 +228,14 @@ script/ # Development utility scripts
183
228
184
229
## Environment Limitations and Workarounds
185
230
186
- - ** Network connectivity required:** Documentation build and pre-commit setup require internet access
187
- - ** Tox failures:** In isolated environments, use direct pytest and pip commands instead of tox
188
- - ** Import errors in self-check:** Some import errors when running pylint on itself are expected (git dependencies not installed)
189
- - ** Build environments:** Use direct pip/pytest commands when tox environments fail to build
190
-
191
- Always validate your changes by running pylint on sample code to ensure functionality works correctly.
231
+ - ** Network connectivity required:** Documentation build and pre-commit setup require
232
+ internet access
233
+ - ** Tox failures:** In isolated environments, use direct pytest and pip commands instead
234
+ of tox
235
+ - ** Import errors in self-check:** Some import errors when running pylint on itself are
236
+ expected (git dependencies not installed)
237
+ - ** Build environments:** Use direct pip/pytest commands when tox environments fail to
238
+ build
239
+
240
+ Always validate your changes by running pylint on sample code to ensure functionality
241
+ works correctly.
0 commit comments