Skip to content

Commit bad3e82

Browse files
Merge remote-tracking branch 'origin/main' into scientific-notation-formatting
2 parents fe1a985 + c708b6a commit bad3e82

File tree

164 files changed

+3056
-1935
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+3056
-1935
lines changed

.coveragerc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ include =
77
pylint/*
88
omit =
99
*/test/*
10-
exclude_lines =
11-
# Re-enable default pragma
12-
pragma: no cover
13-
10+
exclude_also =
1411
# Debug-only code
1512
def __repr__
1613

@@ -20,3 +17,6 @@ exclude_lines =
2017

2118
# Abstract methods are not executed during pytest runs
2219
raise NotImplementedError()
20+
21+
# Fallback cases which should never be executed
22+
raise AssertionError

.github/copilot-instructions.md

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
# Pylint Development Instructions
2+
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.
6+
7+
## Issue Label Guidelines
8+
9+
Before attempting to fix any issue, check the GitHub issue labels using the GitHub API:
10+
11+
- If an issue is labeled with "Astroid", "Needs astroid update", "Needs astroid
12+
constraint", or "Needs astroid Brain 🧠", **ONLY** create regression tests
13+
- Do **NOT** attempt to fix astroid-related issues as you cannot modify astroid from
14+
this repository
15+
- For astroid-related issues, focus on creating comprehensive regression tests that
16+
reproduce the problem
17+
- All other issues can be fixed normally following the standard development workflow
18+
19+
## Development Environment Setup
20+
21+
### Basic Installation
22+
23+
Clone and set up pylint development environment:
24+
25+
- `git clone https://github.com/pylint-dev/pylint` -- clone repository
26+
- `cd pylint` -- enter directory
27+
- `python3 -m venv venv` -- create virtual environment
28+
- `source venv/bin/activate` -- activate virtual environment (Linux/Mac)
29+
- `pip install -r requirements_test_min.txt` -- install test dependencies (~30 seconds)
30+
- `pip install -e .` -- install pylint in editable mode (~30-60 seconds)
31+
32+
### Optional Setup Steps
33+
34+
- `pre-commit install` -- enable pre-commit hooks for autoformatting
35+
- `pip install pre-commit` -- install pre-commit separately if needed
36+
37+
### Astroid Development (if needed)
38+
39+
If working on astroid changes:
40+
41+
- `git clone https://github.com/pylint-dev/astroid.git` -- clone astroid
42+
- `pip install -e astroid/` -- install astroid in editable mode
43+
- `cd astroid/ && git switch my-astroid-dev-branch` -- switch to development branch
44+
45+
## Running Tests
46+
47+
### Core Test Commands
48+
49+
- `pytest tests/test_functional.py -k test_functional` -- run functional tests (~60
50+
seconds, NEVER CANCEL, set timeout to 120+ seconds)
51+
- `pytest tests/` -- run all tests (several minutes, NEVER CANCEL, set timeout to 300+
52+
seconds)
53+
- `python3 -m pytest` -- run tests with local python
54+
- `pytest tests/test_check_parallel.py -v` -- quick test file (~2 seconds)
55+
56+
### Specific Test Types
57+
58+
- **Functional tests:**
59+
`pytest "tests/test_functional.py::test_functional[missing_kwoa_py3]"` -- single
60+
functional test (~1 second)
61+
- **Unit tests:** Located in `/tests/` directory, test specific pylint functionality
62+
- **Configuration tests:** In `/tests/config/functional/` for testing configuration
63+
loading
64+
- **Primer tests:** `pytest -m primer_stdlib --primer-stdlib` -- test on stdlib for
65+
crashes
66+
67+
### Test with Coverage
68+
69+
- `pytest tests/message/ --cov=pylint.message` -- run with coverage
70+
- `coverage html` -- generate HTML coverage report
71+
72+
### Tox Usage (Optional)
73+
74+
- `python -m tox` -- run all tox environments
75+
- `python -m tox -epy313` -- run Python 3.13 suite only
76+
- `python -m tox -epylint` -- run pylint on pylint's codebase
77+
- `python -m tox -eformatting` -- run formatting checks
78+
- `python -m tox --recreate` -- recreate environments (recommended)
79+
- `python -m tox -e py310 -- -k test_functional` -- run specific tests in tox
80+
81+
## Documentation
82+
83+
### Building Documentation
84+
85+
- `make -C doc/ install-dependencies` -- install doc dependencies (~10 seconds)
86+
- `make -C doc/ html` -- build documentation (~3 minutes, NEVER CANCEL, set timeout to
87+
300+ seconds)
88+
- `make -C doc/ clean` -- clean build files when starting from scratch
89+
- `tox -e docs` -- alternative way to build docs
90+
91+
**Network dependency:** Documentation build requires internet access to fetch external
92+
inventories.
93+
94+
## Validation and Quality Checks
95+
96+
### Running Pylint on Code
97+
98+
- `pylint --help` -- verify pylint installation works
99+
- `pylint --disable=all --enable=E,F pylint/` -- run pylint on itself for errors only
100+
(~20 seconds)
101+
- `pylint --rcfile=pylintrc --fail-on=I path/to/your/changes.py` -- standard pylint run
102+
- `pylint --disable=all --enable=E,F,W path/to/your/changes.py` -- focus on errors and
103+
warnings
104+
105+
### Pre-commit and Formatting
106+
107+
- `pre-commit run --all-files` -- run all formatting checks (requires network for
108+
initial setup)
109+
- **Network dependency:** pre-commit may fail in isolated environments due to hook
110+
downloads
111+
112+
### Validation Test Scenarios
113+
114+
Always test your changes with these validation scenarios:
115+
116+
- `echo "def badFunction(): pass" > /tmp/test_sample.py && pylint --enable=C0103 /tmp/test_sample.py`
117+
-- should find naming issues
118+
- `pylint --help` and `pylint --list-msgs | head -10` -- verify CLI functionality
119+
- `pylint --help-msg=C0103` -- should show invalid-name help
120+
- `pylint --rcfile=pylintrc --fail-on=I pylint/__init__.py` -- should get 10.00/10
121+
rating
122+
123+
## Writing Tests
124+
125+
### Functional Tests
126+
127+
Located in `/tests/functional/`, consists of `.py` test files with corresponding `.txt`
128+
expected output files:
129+
130+
- Annotate lines where messages are expected:
131+
`a, b, c = 1 # [unbalanced-tuple-unpacking]`
132+
- Multiple messages on same line:
133+
`a, b, c = 1.test # [unbalanced-tuple-unpacking, no-member]`
134+
- Use offset syntax for special cases: `# +1: [singleton-comparison]`
135+
- **Run and update:**
136+
`python tests/test_functional.py --update-functional-output -k "test_functional[test_name]"`
137+
138+
### Test File Organization
139+
140+
- **New checkers:** Create `new_checker_message.py` in `/tests/functional/n/`
141+
- **Extensions:** Place in `/tests/functional/ext/extension_name/`
142+
- **Regression tests:** Place in `/tests/r/regression/` with `regression_` prefix
143+
- **Configuration tests:** Place in `/tests/config/functional/`
144+
145+
### Configuration Test Files
146+
147+
Create `.result.json` files with configuration differences from standard config:
148+
149+
```json
150+
{
151+
"functional_append": {
152+
"disable": [["a-message-to-be-added"]]
153+
},
154+
"jobs": 10
155+
}
156+
```
157+
158+
## Codebase Structure
159+
160+
```
161+
pylint/ # Main package
162+
├── checkers/ # All pylint checkers (rules implementation)
163+
├── config/ # Configuration handling and parsing
164+
├── message/ # Message system and formatting
165+
├── reporters/ # Output formatters (text, json, etc.)
166+
├── testutils/ # Testing utilities and helpers
167+
└── extensions/ # Optional extensions and plugins
168+
169+
tests/ # Test suite
170+
├── functional/ # Functional test files (.py + .txt expected output)
171+
├── config/functional/ # Configuration functional tests
172+
├── r/regression/ # Regression tests
173+
├── test_*.py # Unit tests
174+
└── regrtest_data/ # Test data files
175+
176+
doc/ # Documentation
177+
├── user_guide/ # User documentation
178+
├── development_guide/ # Developer and contributor documentation
179+
│ ├── contributor_guide/ # Setup, testing, contribution guidelines
180+
│ ├── technical_reference/ # Technical implementation details
181+
│ └── how_tos/ # Guides for custom checkers, plugins
182+
└── additional_tools/ # Tools documentation
183+
184+
script/ # Development utility scripts
185+
```
186+
187+
### Key Files
188+
189+
- `pyproject.toml` -- Main configuration (dependencies, build, tools)
190+
- `tox.ini` -- Multi-environment testing configuration
191+
- `.pre-commit-config.yaml` -- Code quality checks configuration
192+
- `pylintrc` -- Pylint's own configuration
193+
- `requirements_test_min.txt` -- Minimal test dependencies
194+
- `.gitignore` do not add the 'venv' inside the .gitignore, don't commit the venv in the
195+
first place (humans add it to their global gitignore)
196+
197+
## Creating New Checkers
198+
199+
### Getting Started
200+
201+
- `python script/get_unused_message_id_category.py` -- get next available message ID
202+
- Study existing checkers in `pylint/checkers/` for patterns
203+
- Read technical reference documentation in `doc/development_guide/technical_reference/`
204+
- Use `astroid.extract_node` for AST manipulation
205+
206+
### Workflow
207+
208+
1. Create checker class in appropriate `pylint/checkers/` file
209+
2. Add functional tests in `tests/functional/`
210+
3. Search existing code for warning message to find where logic exists
211+
4. Test with sample code to ensure functionality works
212+
213+
## Pull Request Guidelines
214+
215+
### Before Submitting
216+
217+
- Use Python 3.8+ for development (required for latest AST parser and pre-commit hooks)
218+
- Write comprehensive commit messages relating to tracker issues
219+
- Keep changes small and separate consensual from opinionated changes
220+
- Add news fragment: `towncrier create <IssueNumber>.<type>`
221+
- Always launch `pre-commit run -a` before committing
222+
223+
### Documentation Changes
224+
225+
- Document non-trivial changes
226+
- Generate docs with `tox -e docs`
227+
- Maintainers may label issues `skip-news` if no changelog needed
228+
229+
### Contribution Credits
230+
231+
- Add emails/names to `script/.contributors_aliases.json` if using multiple identities
232+
233+
## Critical Timing Information
234+
235+
- **NEVER CANCEL:** All operations that show "NEVER CANCEL" may take significant time
236+
- **Full test suite:** 60+ seconds (set timeout to 120+ seconds)
237+
- **Documentation build:** 180 seconds (set timeout to 300+ seconds)
238+
- **Functional tests:** 60 seconds (set timeout to 120+ seconds)
239+
- **Pylint self-check:** 20 seconds (set timeout to 60+ seconds)
240+
- **Individual test files:** 1-15 seconds
241+
- **Installation steps:** 30-60 seconds each
242+
243+
## Environment Limitations and Workarounds
244+
245+
- **Network connectivity required:** Documentation build and pre-commit setup require
246+
internet access
247+
- **Tox failures:** In isolated environments, use direct pytest and pip commands instead
248+
of tox
249+
- **Import errors in self-check:** Some import errors when running pylint on itself are
250+
expected (git dependencies not installed)
251+
- **Build environments:** Use direct pip/pytest commands when tox environments fail to
252+
build
253+
254+
Always validate your changes by running pylint on sample code to ensure functionality
255+
works correctly.

.github/workflows/backport.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ jobs:
2525
)
2626
)
2727
steps:
28-
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
28+
- uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
2929
id: app-token
3030
with:
31-
app-id: ${{ vars.APP_ID }}
31+
app-id: ${{ vars.BACKPORT_APP_ID }}
3232
private-key: ${{ secrets.PRIVATE_KEY }}
3333
permission-contents: write # push branch to Github
3434
permission-pull-requests: write # create PR / add comment for manual backport
3535
permission-workflows: write # modify files in .github/workflows
36-
- uses: tibdex/backport@9565281eda0731b1d20c4025c43339fb0a23812e # v2.0.4
36+
- uses: pylint-dev/backport@94367840595495e101f9a31415897c05da1f08d9 # v2.1.1
3737
with:
3838
github_token: ${{ steps.app-token.outputs.token }}
39+
user_name: ${{ vars.BACKPORT_USER_NAME }}
40+
user_email: ${{ vars.BACKPORT_USER_EMAIL }}

.github/workflows/changelog.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ jobs:
2121
timeout-minutes: 10
2222
steps:
2323
- name: Check out code from GitHub
24-
uses: actions/checkout@v4.2.2
24+
uses: actions/checkout@v5.0.0
2525
with:
2626
# `towncrier check` runs `git diff --name-only origin/main...`, which
2727
# needs a non-shallow clone.
2828
fetch-depth: 0
2929
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
3030
id: python
31-
uses: actions/setup-python@v5.6.0
31+
uses: actions/setup-python@v6.0.0
3232
with:
3333
python-version: ${{ env.DEFAULT_PYTHON }}
3434
check-latest: true
@@ -41,7 +41,7 @@ jobs:
4141
$GITHUB_OUTPUT
4242
- name: Restore Python virtual environment
4343
id: cache-venv
44-
uses: actions/[email protected].3
44+
uses: actions/[email protected].4
4545
with:
4646
path: venv
4747
key: >-

0 commit comments

Comments
 (0)