Linter Formatter - makersacademy/simpleassettracker GitHub Wiki
This project uses Pylint as a tool to check for errors in Python code. In particular:
- Version 2.4.4
-
pylint==2.4.4is already included in the <requirements.txt> file.
The default coding style used by Pylint is close to PEP 8.
Specifying all the options suitable for your setup and coding standards can be tedious, so it is possible to use a configuration file to specify the default values. You can specify a configuration file on the command line using the --rcfile option
# Using an *nix shell or cmd on Windows
pylint --generate-rcfile > .pylintrc- It creates a
.pylintrcfile under your current working directory
which pylintpylint AssetTracker/<file-name>.py
pylint AssetTracker/<folder-name>/<file-name>.pypylint AssetTracker/apps/assets/serializers.py
************* Module simpleassettracker.AssetTracker.apps.assets.serializers
AssetTracker/apps/assets/serializers.py:7:0: C0301: Line too long (182/100) (line-too-long)
AssetTracker/apps/assets/serializers.py:5:1: R0903: Too few public methods (0/2) (too-few-public-methods)
-----------------------------------
Your code has been rated at 6.67/10Ignores the following directories and files:
# line 10 - .pylintrc
ignore= migrations, admin.py
Does not show warnings:
disable=...
...
missing-module-docstring,
missing-class-docstring
Indentation unit is #tab:
# line 326
indent-string='\t'
Important: Please note that when you write code, you might need to do further configuration in your editor/IDE to specify indentation using tabs.
-
How to add pylint-django plug-in
-
urlpatternsIt shows a wrong hanging indentation error (C0330). While in most cases pylint is right,
urlpatternscomes with Django and we want to keep it as it is.- One solution is to add
# pylint: disable=bad-continuationto everyurls.pyfile like in the following example:# AssetTracker/apps/dashboard/urls.py # pylint: disable=bad-continuation # pylint: disable=invalid-name urlpatterns = [ path('dashboard', dashboardPageView, name='home') ]
- Another solution is to change
indent-after-paren=4toindent-after-paren=1in the configuration file. The latter might affect blocks of code that have already been checked with pylint.
It shows a naming convention error (C0103 -
Constant name "urlpatterns" doesn't conform to UPPER_CASE naming style (invalid-name)). One solution is to add#pylint: disable=invalid-nameto everyurls.py - One solution is to add