|
| 1 | +# Pylint Development Instructions |
| 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. |
| 4 | + |
| 5 | +## Working Effectively |
| 6 | + |
| 7 | +- Bootstrap and set up the development environment: |
| 8 | + - `python --version` -- verify Python 3.10+ is available |
| 9 | + - `pip install -e .` -- install pylint in development mode (takes ~30-60 seconds) |
| 10 | + - `pip install coverage pytest pytest-cov pytest-xdist tox` -- install core test dependencies |
| 11 | + |
| 12 | +- Run basic validation: |
| 13 | + - `pylint --help` -- verify pylint is working correctly |
| 14 | + - `pylint --disable=all --enable=E,F pylint/` -- run pylint on itself for errors only (takes ~20 seconds, some import errors expected) |
| 15 | + |
| 16 | +- Run tests: |
| 17 | + - `pytest tests/test_check_parallel.py -v` -- run a quick test file (~2 seconds) |
| 18 | + - `pytest tests/test_self.py -v` -- run core functionality tests (~15 seconds) |
| 19 | + - `pytest tests/test_functional.py::test_functional --maxfail=5 -q` -- run functional tests (takes ~60 seconds, NEVER CANCEL, set timeout to 120+ seconds) |
| 20 | + - **NEVER CANCEL:** Full test suite takes 60+ seconds. Always wait for completion. |
| 21 | + |
| 22 | +- Install additional development dependencies: |
| 23 | + - `pip install pre-commit` -- for code formatting and linting |
| 24 | + - `cd doc && pip install -r requirements.txt` -- for documentation (requires network access) |
| 25 | + |
| 26 | +- Build documentation: |
| 27 | + - `cd doc && make install-dependencies` -- install doc dependencies (~10 seconds) |
| 28 | + - `cd doc && make html` -- build documentation (~3 minutes, NEVER CANCEL, may fail without network access) |
| 29 | + - **NEVER CANCEL:** Documentation build takes up to 3 minutes. Set timeout to 300+ seconds. |
| 30 | + |
| 31 | +## Validation |
| 32 | + |
| 33 | +- Always run pylint on your changes before committing: |
| 34 | + - `pylint --rcfile=pylintrc --fail-on=I path/to/your/changes.py` -- standard pylint run |
| 35 | + - `pylint --disable=all --enable=E,F,W path/to/your/changes.py` -- focus on errors and warnings |
| 36 | + |
| 37 | +- Run formatting and pre-commit checks: |
| 38 | + - `pre-commit run --all-files` -- run all formatting checks (requires network for initial setup) |
| 39 | + - **Network dependency:** pre-commit may fail in isolated environments due to hook downloads |
| 40 | + |
| 41 | +- **VALIDATION SCENARIOS:** Always test your changes by: |
| 42 | + - Running pylint on a sample Python file: `echo "def badFunction(): pass" > /tmp/test_sample.py && pylint --enable=C0103 /tmp/test_sample.py` (should find naming issues) |
| 43 | + - Verifying pylint CLI still works: `pylint --help` and `pylint --list-msgs | head -10` |
| 44 | + - Testing message ID functionality: `pylint --help-msg=C0103` (should show invalid-name help) |
| 45 | + - Checking specific module: `pylint --rcfile=pylintrc --fail-on=I pylint/__init__.py` (should get 10.00/10 rating) |
| 46 | + |
| 47 | +## Common Tasks |
| 48 | + |
| 49 | +### Running specific test categories: |
| 50 | +- Functional tests: `pytest tests/test_functional.py -k "test_name" -v` |
| 51 | +- Individual functional test: `pytest "tests/test_functional.py::test_functional[abstract_class_instantiated]" -v` (~1 second) |
| 52 | +- Unit tests: `pytest tests/test_self.py -v` |
| 53 | +- Quick smoke test: `pytest tests/test_func.py tests/test_check_parallel.py -v` (~2 seconds, 53 tests) |
| 54 | + |
| 55 | +### Understanding the codebase structure: |
| 56 | +``` |
| 57 | +pylint/ # Main package |
| 58 | +├── checkers/ # All pylint checkers (rules) |
| 59 | +├── config/ # Configuration handling |
| 60 | +├── message/ # Message system |
| 61 | +├── reporters/ # Output formatters |
| 62 | +├── testutils/ # Testing utilities |
| 63 | +└── extensions/ # Optional extensions |
| 64 | +
|
| 65 | +tests/ # Test suite |
| 66 | +├── functional/ # Functional test files (.py files with expected output) |
| 67 | +├── test_*.py # Unit tests |
| 68 | +└── data/ # Test data files |
| 69 | +
|
| 70 | +doc/ # Documentation |
| 71 | +├── user_guide/ # User documentation |
| 72 | +├── development_guide/ # Developer documentation |
| 73 | +└── additional_tools/ # Tools documentation |
| 74 | +``` |
| 75 | + |
| 76 | +### Key files to know: |
| 77 | +- `pyproject.toml` -- Main configuration (dependencies, build, tools) |
| 78 | +- `tox.ini` -- Multi-environment testing configuration |
| 79 | +- `.pre-commit-config.yaml` -- Code quality checks configuration |
| 80 | +- `pylintrc` -- Pylint's own configuration |
| 81 | +- `script/` -- Utility scripts for development |
| 82 | + |
| 83 | +### Creating new checkers: |
| 84 | +- Use `python script/get_unused_message_id_category.py` to get unused message IDs (outputs next available ID) |
| 85 | +- Look at existing checkers in `pylint/checkers/` for patterns |
| 86 | +- Add functional tests in `tests/functional/` |
| 87 | + |
| 88 | +### Working with functional tests: |
| 89 | +- Tests are in `tests/functional/` with `.py` files and corresponding `.txt` files for expected output |
| 90 | +- Run individual functional test: `pytest tests/test_functional.py::test_functional[test_name] -v` |
| 91 | + |
| 92 | +## Critical Timing Information |
| 93 | + |
| 94 | +- **NEVER CANCEL:** All operations that show "NEVER CANCEL" may take significant time |
| 95 | +- Functional test suite: 60 seconds (set timeout to 120+ seconds) |
| 96 | +- Documentation build: 180 seconds (set timeout to 300+ seconds) |
| 97 | +- Full pylint self-check: 20 seconds (set timeout to 60+ seconds) |
| 98 | +- Individual test files: 1-15 seconds |
| 99 | + |
| 100 | +## Known Issues and Workarounds |
| 101 | + |
| 102 | +- **Network connectivity required:** Documentation build and pre-commit setup require internet access |
| 103 | +- **Tox may fail:** In isolated environments, use direct pytest and pip commands instead of tox |
| 104 | +- **Import errors in self-check:** Some import errors when running pylint on itself are expected (git dependencies not installed) |
| 105 | + |
| 106 | +## Environment Limitations |
| 107 | + |
| 108 | +- Some network-dependent operations may fail in isolated environments |
| 109 | +- Use direct pip and pytest commands when tox environments fail to build |
| 110 | +- Documentation build requires network access to fetch external inventories |
| 111 | + |
| 112 | +Always build and exercise your changes by running pylint on sample code to ensure functionality works correctly. |
0 commit comments