{"id":682,"library":"pylint","title":"Pylint","description":"Pylint is a widely used static code analyzer for Python. It inspects source code without execution to detect programming errors, enforce coding standards (like PEP 8), identify code smells, and suggest refactorings. It provides a detailed report and a code quality score. Pylint maintains an active development status with regular releases, including minor versions for new checks and bug fixes, and major versions that may introduce breaking changes to options or output formats.","status":"active","version":"4.0.5","language":"python","source_language":"en","source_url":"https://github.com/PyCQA/pylint","tags":["linter","static analysis","code quality","PEP 8","developer tools"],"install":[{"cmd":"pip install pylint","lang":"bash","label":"Standard Installation"},{"cmd":"pip install pylint[spelling]","lang":"bash","label":"With Spelling Checks (requires Enchant C library)"}],"dependencies":[{"reason":"Pylint's core for Abstract Syntax Tree (AST) inference and representation.","package":"astroid","optional":false},{"reason":"Version requirement for isort was bumped to >=5.0.0 in Pylint 4.x releases.","package":"isort","optional":false}],"imports":[{"note":"Used for programmatic invocation of Pylint.","symbol":"Run","correct":"from pylint.lint import Run"},{"note":"Useful for capturing Pylint's output to a custom stream when running programmatically.","symbol":"TextReporter","correct":"from pylint.reporters.text import TextReporter"}],"quickstart":{"code":"import os\nimport io\nfrom pylint.lint import Run\nfrom pylint.reporters.text import TextReporter\n\n# Create a dummy Python file for linting\nwith open('my_module.py', 'w') as f:\n    f.write('\"\"\"A simple module.\"\"\"\nMY_CONSTANT = 10\ndef my_function(arg1, arg2):  # arg2 is unused\n    return arg1 + MY_CONSTANT\n')\n\n# --- Command Line Usage ---\nprint(\"\\n--- Command Line Pylint ---\")\nos.system('pylint my_module.py')\n\n# --- Programmatic Usage ---\nprint(\"\\n--- Programmatic Pylint ---\")\n# Capture output to a string buffer\npylint_output = io.StringIO()\nreporter = TextReporter(pylint_output)\n\n# Run Pylint on the module, disabling reports for cleaner output\n# do_exit=False prevents sys.exit() on linting issues\nRun(['my_module.py', '--disable=C0114,C0116,R0903', '--reports=no'], reporter=reporter, do_exit=False)\n\nprint(pylint_output.getvalue())\n\n# Clean up the dummy file\nos.remove('my_module.py')","lang":"python","description":"The most common way to use Pylint is via the command line, simply by pointing it to a Python file, module, or package. For integration into tools or CI/CD pipelines, Pylint can also be invoked programmatically using `pylint.lint.Run`, allowing for custom reporters and output handling. The quickstart demonstrates both methods."},"warnings":[{"fix":"Replace `from pylint import __pkginfo__` with `from importlib import metadata; metadata.metadata('pylint')`.","message":"Pylint 4.x removes direct access to package metadata via `pylint.__pkginfo__`. Users should migrate to `importlib.metadata` for retrieving package information.","severity":"breaking","affected_versions":"4.0.0+"},{"fix":"Ensure that the Python interpreter used to install and run Pylint is 3.10.0 or newer. If linting older Python code, use the `--py-version` flag.","message":"Pylint 4.x officially drops support for *launching* Pylint with Python 3.9. While it can still *lint* code written for Python 3.9 (or older) using `--py-version=3.9`, the environment running Pylint itself must be Python 3.10.0 or newer.","severity":"breaking","affected_versions":"4.0.0+"},{"fix":"Review configuration files and command-line arguments to ensure the intended message enabling/disabling order is maintained. Avoid redundant or conflicting `enable=all`/`disable=all` with specific message controls.","message":"In Pylint 3.x, the behavior of enabling or disabling individual messages changed. The order of `--enable` or `--disable` flags (or their counterparts in configuration files) now strictly dictates their application, meaning later options can override earlier ones.","severity":"breaking","affected_versions":"3.0.0+"},{"fix":"During initial adoption, start with `--errors-only` or disable convention/refactor messages (e.g., `--disable=C,R`) and progressively re-enable checks as code quality improves. Generate a `.pylintrc` file (`pylint --generate-rcfile > .pylintrc`) for granular control over messages and checkers.","message":"Pylint's default configuration can be very verbose, especially on legacy or less-PEP 8 compliant projects. This often leads to an overwhelming number of messages upon first run.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Customize the regular expressions for naming conventions in your `.pylintrc` file. For instance, modify `--const-rgx` or `--variable-rgx` to match your project's style.","message":"The `invalid-name` message often triggers due to Pylint's default expectation of `UPPERCASE` for module-level constants, which might conflict with project-specific naming conventions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always run Pylint from the project root or a directory where Python can correctly resolve your modules. Verify your `PYTHONPATH` environment variable if encountering import issues.","message":"Pylint relies on Python's module resolution mechanism. Incorrect `PYTHONPATH` settings or running Pylint from an unexpected working directory can lead to it analyzing the wrong module version or failing to import modules, resulting in `import-error` messages.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Before running Pylint, ensure that the target Python script is free of basic syntax errors. Correct the `SyntaxError` in the script as indicated by the Python interpreter (e.g., unclosed string literals, unmatched parentheses/brackets).","message":"The Python script being linted contains a fundamental `SyntaxError`, preventing Pylint from analyzing the code. Pylint cannot process files that are not valid Python.","severity":"breaking","affected_versions":"All versions"},{"fix":"Correct the syntax error in the relevant Python script (e.g., ensure all string literals are properly terminated) before attempting to run the test or Pylint.","message":"The script executed as part of the test setup contains a fundamental Python syntax error, preventing its successful execution. This is independent of Pylint's behavior or specific version.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T17:47:45.098Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Add a triple-quoted string (docstring) at the very top of your Python file, after the shebang but before any code or imports. \n```python\n\"\"\"A brief description of what this module does.\"\"\"\n\n# Your code starts here\nimport os\n```","cause":"Pylint requires Python modules to have a docstring at the beginning of the file to explain the module's purpose, as per coding style conventions like PEP 257.","error":"missing-module-docstring"},{"fix":"Ensure the module is installed in the correct environment (e.g., `pip install your-module`). If it's a local module, ensure its containing directory is on the `PYTHONPATH` or configure Pylint's `init-hook` in `.pylintrc` to add the path. For Visual Studio Code, select the correct Python interpreter for your project.","cause":"Pylint cannot find the specified module because it's not in Python's `sys.path`, often due to an incorrect virtual environment, a custom module not being on the path, or a misspelled import statement.","error":"pylint Unable to import"},{"fix":"Double-check the spelling of the imported name. Verify that the name is indeed available in the module you are importing from. If it's a dynamic import or Pylint's analysis is failing, you might need to add `ignored-modules` or `generated-members` to your `.pylintrc` or use an inline disable comment `# pylint: disable=no-name-in-module`.","cause":"Pylint reports this error when a specific name (function, class, variable) imported from a module cannot be found within that module. This can happen if the name is misspelled, not actually exported by the module, or if Pylint has trouble analyzing the module due to complex imports or dynamic code.","error":"pylint no-name-in-module (E0611)"},{"fix":"Remove the unused import statement. If the import is necessary for some reason (e.g., for side effects or for a `__init__.py` exposing submodules), you can disable the warning for that specific line or file using `# pylint: disable=unused-import` or configure `good-names` for specific cases.","cause":"This warning occurs when a module or a specific name imported from a module is not used anywhere in the code that follows the import statement, indicating potentially unnecessary code.","error":"pylint unused-import (W0611)"},{"fix":"Ensure Pylint is installed in your current Python environment (`pip install pylint`). If installed, locate the Pylint executable (often in `Scripts/` on Windows or `bin/` in a Unix-like environment within your Python installation or virtual environment) and add that directory to your system's PATH. Alternatively, run Pylint using `python -m pylint [options] <files>`.","cause":"The 'pylint' command is not recognized by your system's shell because the directory where Pylint is installed is not included in your system's PATH environment variable, or Pylint was not installed correctly.","error":"pylint: command not found"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"4.0.5","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.41,"mem_mb":12.5,"disk_size":"26.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.41,"mem_mb":12.5,"disk_size":"27.2M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.42,"mem_mb":12.5,"disk_size":"26.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.44,"mem_mb":12.5,"disk_size":"27.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.6,"import_time_s":0.29,"mem_mb":12.5,"disk_size":"27M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.6,"import_time_s":0.29,"mem_mb":12.5,"disk_size":"28M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.3,"mem_mb":12.5,"disk_size":"27M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.3,"mem_mb":12.5,"disk_size":"28M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.58,"mem_mb":13.2,"disk_size":"30.0M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.58,"mem_mb":13.2,"disk_size":"30.4M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.64,"mem_mb":13.1,"disk_size":"30.0M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.96,"mem_mb":13.1,"disk_size":"30.4M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.6,"import_time_s":0.53,"mem_mb":13.2,"disk_size":"31M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.8,"import_time_s":0.52,"mem_mb":13.2,"disk_size":"31M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.49,"mem_mb":13.1,"disk_size":"30M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.5,"mem_mb":13.1,"disk_size":"31M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.55,"mem_mb":12.9,"disk_size":"21.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.51,"mem_mb":12.9,"disk_size":"21.9M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.59,"mem_mb":12.9,"disk_size":"21.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.62,"mem_mb":12.9,"disk_size":"21.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.6,"import_time_s":0.55,"mem_mb":12.9,"disk_size":"22M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.5,"import_time_s":0.57,"mem_mb":12.9,"disk_size":"22M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.54,"mem_mb":12.9,"disk_size":"22M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.52,"mem_mb":12.9,"disk_size":"22M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.52,"mem_mb":13.6,"disk_size":"21.3M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.5,"mem_mb":13.6,"disk_size":"21.7M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.54,"mem_mb":13.5,"disk_size":"21.1M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.53,"mem_mb":13.5,"disk_size":"21.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.4,"import_time_s":0.5,"mem_mb":13.6,"disk_size":"22M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.6,"import_time_s":0.5,"mem_mb":13.6,"disk_size":"22M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.53,"mem_mb":13.5,"disk_size":"22M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.55,"mem_mb":13.5,"disk_size":"22M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.53,"mem_mb":14.5,"disk_size":"26.6M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.53,"mem_mb":14.5,"disk_size":"26.9M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.53,"mem_mb":14.5,"disk_size":"26.5M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.54,"mem_mb":14.5,"disk_size":"26.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":3.2,"import_time_s":0.52,"mem_mb":14.6,"disk_size":"27M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":3.3,"import_time_s":0.5,"mem_mb":14.6,"disk_size":"27M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.48,"mem_mb":14.6,"disk_size":"27M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"spelling","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.45,"mem_mb":14.6,"disk_size":"27M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}