@pycheck/cli
v0.7.3
Published
An opinionated code quality checker for Python, terminal client
Readme
Pycheck
An opinionated code quality checker for Python. Pycheck runs some code checking tools, shows the problems and generates a note for the code. Checks:
- Formating with Black
- Codestyle with Flake8
- Typing with Pyright
Install
Requirements: to have the base tools installed: Black, Flake8 and Pyright:
# install the python packages
pip install black flake8 pyrightInstall Pycheck:
yarn global add @pycheck/cli
# or
npm install -g @pycheck/cliThis way you can run pycheck in any project directory
Run
To run Pycheck vs any python directory:
pycheck /my/python/dirWith no parameters it will run in the current directory, looking for python code
Available options:
-s: display suggestions about how to resolve the problems-v: will display more info (the list of files to format)--debug: print the commands--disable-typing: an option to not run the Pyright checks, just Flake and Black
Presets
Some presets options are available for the level of checks:
--untyped: to run with permissive type checking--django: to run for a Django project
Example with options:
pycheck -s --untypedIt is possible to declare a preset in the setup.cfg file in your project instead
of using a command line flag:
[pycheck]
preset = djangoIgnore options
Pyright
To ignore files in Pyright declare the list in a pyrightconfig.json file at the root
of your project:
{
"exclude": [
"build",
"dist"
]
}Flake
To ignore files in Flake8 declare a section in your setup.cfg file:
[flake8]
max-line-length = 88
exclude = .git,.venv,build,__pycache__,*/migrations/*Black
By default the exclude list for Black will use the one of Flake if declared. To
disable this behavior, in setup.cfg:
[pycheck]
black-ignore = disabledTo provide a custom regex ignore string to Black:
[pycheck]
black-ignore = '\\.git|\\.venv|build|__pycache__|\\*/migrations/\\*'Example output:
Using preset untyped
Checking formatting with Black ...
Checking codestyle with Flake8 ...
Checking typing with Pyright ...
-----------------------
☢️ Found some problems:
-----------------------
🔴 (3) sandbox/settings/tests.py
- 1: F403 'from sandbox.settings.base import *' used; unable to detect undefined names
- 14: F405 'join' may be undefined, or defined from star imports: sandbox.settings.base
- 19: F405 'VAR_PATH' may be undefined, or defined from star imports: sandbox.settings.base
🔴 (2) docs/conf.py
- 1: E402 module level import not at top of file
- 1: E402 module level import not at top of file
🔴 (5) docs/django_settings.py
- 1: F401 'os.listdir' imported but unused
- 1: F401 'os.path.normpath' imported but unused
- 1: E402 module level import not at top of file
- 1: F403 'from demospa.settings import *' used; unable to detect undefined names
- 1: F401 'demospa.settings.*' imported but unused
🔴 (1) sandbox/settings/demo.py
- 1: F403 'from sandbox.settings.base import *' used; unable to detect undefined names
🔵 (4) sandbox/settings/tests.py
- 11: "join" is not defined (reportUndefinedVariable)
- 11: "VAR_PATH" is not defined (reportUndefinedVariable)
- 18: "join" is not defined (reportUndefinedVariable)
- 18: "VAR_PATH" is not defined (reportUndefinedVariable)
🔵 (2) sandbox/settings/demo.py
- 12: "join" is not defined (reportUndefinedVariable)
- 12: "VAR_PATH" is not defined (reportUndefinedVariable)
⚫ 25 files could be formated
Code score: 68/100
- Formating: 0/10
- Codestyle: 44/60
- Typing: 24/30