11# Pylint Development Instructions
22
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.
46
57## Development Environment Setup
68
79### Basic Installation
10+
811Clone and set up pylint development environment:
12+
913- ` git clone https://github.com/pylint-dev/pylint ` -- clone repository
1014- ` cd pylint ` -- enter directory
1115- ` python3 --version ` -- verify Python 3.8+ is available (development requires 3.8+)
@@ -15,34 +19,47 @@ Clone and set up pylint development environment:
1519- ` pip install -e . ` -- install pylint in editable mode (~ 30-60 seconds)
1620
1721### Optional Setup Steps
22+
1823- ` pre-commit install ` -- enable pre-commit hooks for autoformatting
1924- ` pip install pre-commit ` -- install pre-commit separately if needed
2025
2126### Astroid Development (if needed)
27+
2228If working on astroid changes:
29+
2330- ` git clone https://github.com/pylint-dev/astroid.git ` -- clone astroid
2431- ` pip install -e astroid/ ` -- install astroid in editable mode
2532- ` cd astroid/ && git switch my-astroid-dev-branch ` -- switch to development branch
2633
2734## Running Tests
2835
2936### 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)
3242- ` python3 -m pytest ` -- run tests with local python
3343- ` pytest tests/test_check_parallel.py -v ` -- quick test file (~ 2 seconds)
3444
3545### 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)
3750- ** 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
4055
4156### Test with Coverage
57+
4258- ` pytest tests/message/ --cov=pylint.message ` -- run with coverage
4359- ` coverage html ` -- generate HTML coverage report
4460
4561### Tox Usage (Optional)
62+
4663- ` python -m tox ` -- run all tox environments
4764- ` python -m tox -epy313 ` -- run Python 3.13 suite only
4865- ` python -m tox -epylint ` -- run pylint on pylint's codebase
@@ -53,55 +70,77 @@ If working on astroid changes:
5370## Documentation
5471
5572### Building Documentation
73+
5674- ` 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)
5877- ` make -C doc/ clean ` -- clean build files when starting from scratch
5978- ` tox -e docs ` -- alternative way to build docs
6079
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.
6282
6383## Validation and Quality Checks
6484
6585### Running Pylint on Code
86+
6687- ` 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)
6890- ` 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
7093
7194### 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
74100
75101### Validation Test Scenarios
102+
76103Always 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
78107- ` pylint --help ` and ` pylint --list-msgs | head -10 ` -- verify CLI functionality
79108- ` 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
81111
82112## Writing Tests
83113
84114### 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] `
88123- 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]" `
90126
91127### Test File Organization
128+
92129- ** New checkers:** Create ` new_checker_message.py ` in ` /tests/functional/n/ `
93130- ** Extensions:** Place in ` /tests/functional/ext/extension_name/ `
94131- ** Regression tests:** Place in ` /tests/r/regression/ ` with ` regression_ ` prefix
95132- ** Configuration tests:** Place in ` /tests/config/functional/ `
96133
97134### Configuration Test Files
135+
98136Create ` .result.json ` files with configuration differences from standard config:
137+
99138``` json
100139{
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
105144}
106145```
107146
@@ -135,21 +174,24 @@ script/ # Development utility scripts
135174```
136175
137176### Key Files
177+
138178- ` pyproject.toml ` -- Main configuration (dependencies, build, tools)
139179- ` tox.ini ` -- Multi-environment testing configuration
140- - ` .pre-commit-config.yaml ` -- Code quality checks configuration
180+ - ` .pre-commit-config.yaml ` -- Code quality checks configuration
141181- ` pylintrc ` -- Pylint's own configuration
142182- ` requirements_test_min.txt ` -- Minimal test dependencies
143183
144184## Creating New Checkers
145185
146186### Getting Started
187+
147188- ` python script/get_unused_message_id_category.py ` -- get next available message ID
148189- Study existing checkers in ` pylint/checkers/ ` for patterns
149190- Read technical reference documentation in ` doc/development_guide/technical_reference/ `
150191- Use ` astroid.extract_node ` for AST manipulation
151192
152193### Workflow
194+
1531951 . Create checker class in appropriate ` pylint/checkers/ ` file
1541962 . Add functional tests in ` tests/functional/ `
1551973 . Search existing code for warning message to find where logic exists
@@ -158,17 +200,20 @@ script/ # Development utility scripts
158200## Pull Request Guidelines
159201
160202### Before Submitting
203+
161204- Use Python 3.8+ for development (required for latest AST parser and pre-commit hooks)
162205- Write comprehensive commit messages relating to tracker issues
163206- Keep changes small and separate consensual from opinionated changes
164207- Add news fragment: ` towncrier create <IssueNumber>.<type> `
165208
166209### Documentation Changes
210+
167211- Document non-trivial changes
168212- Generate docs with ` tox -e docs `
169213- Maintainers may label issues ` skip-news ` if no changelog needed
170214
171215### Contribution Credits
216+
172217- Add emails/names to ` script/.contributors_aliases.json ` if using multiple identities
173218
174219## Critical Timing Information
@@ -183,9 +228,14 @@ script/ # Development utility scripts
183228
184229## Environment Limitations and Workarounds
185230
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