0.6.1 ā€¢ Published 1 year ago

pycheck v0.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Pycheck

npm package

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 pyright

Install Pycheck:

yarn global add pycheck
# or 
npm install -g pycheck

This way you can run pycheck in any project directory

Run

To run Pycheck vs any python directory:

pycheck /my/python/dir

With 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 --untyped

It is possible to declare a preset in the setup.cfg file in your project instead of using a command line flag:

[pycheck]
preset = django

Ignore 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 = disabled

To 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
0.5.5

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.4

2 years ago

0.3.0

2 years ago

0.5.3

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.5.2

2 years ago

0.4.3

2 years ago

0.5.1

2 years ago

0.4.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago