-
Notifications
You must be signed in to change notification settings - Fork 0
Pylint Usage Guide
Maksym Derkach edited this page Dec 13, 2024
·
1 revision
Pylint is a static code analysis tool for Python that helps maintain code quality. This guide explains how to run Pylint locally and interpret the results.
-
Open the terminal in the root directory of your Django project.
-
Run Pylint on your application folder (replace
your_django_app_folder):pylint --load-plugins pylint_django your_django_app_folder
-
View the output: Pylint will display issues, including errors, warnings, and suggestions.
- Error (E): Critical issues, e.g., syntax errors.
- Warning (W): Potential issues, e.g., code style violations.
- Refactor (R): Suggestions for simplifying code.
- Convention (C): Naming or formatting issues.
- Missing Docstrings: Add docstrings to functions/classes.
- No Member: Warning for dynamic attributes (common in Django). Can be ignored.
- Invalid Naming: Ensure variable names follow conventions (e.g., snake_case for variables).
************* Module forum.views
forum/views.py:5:0: C0301: Line too long (130/120)
forum/views.py:10:0: W0201: Attribute 'db_field' defined outside __init__
forum/views.py:15:0: C0103: Variable name "foo" doesn't conform to snake_case
- Refactor Code: Simplify functions or methods.
-
Follow Naming Conventions: Use
snake_casefor variables/functions,PascalCasefor classes. - Add Docstrings: Document functions/classes.
-
Ignore False Positives: Modify
.pylintrcto disable specific warnings (e.g., dynamic attributes).
[MESSAGES CONTROL]
disable=missing-docstring,no-member,invalid-name