npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pycheck

v0.6.1

Published

An opinionated code quality checker for Python

Downloads

22

Readme

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