Skip to main content

An intelligent cross-platform wrapper for pyright that makes it less noisy.

Project description

pyright-polite

PyPi Version License Continuous Integration Code Coverage Python Versions


pyright-polite is an intelligent cross-platform wrapper for pyright that makes it less noisy.

Force pyright to be more respectful with your attention :rotating_light:

What does it do?

With pyright-polite:

$ pyright-polite
Found 7 source files
0 errors, 0 warnings, 0 informations

Without:

$ pyright
WARNING: there is a new pyright version available (v1.1.300 -> v1.1.301).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`

No configuration file found.
pyproject.toml file found at /projects/pyright_polite.
Loading pyproject.toml file at /projects/pyright_polite/pyproject.toml
Assuming Python version 3.11
Assuming Python platform Linux
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
stubPath /projects/pyright_polite/typings is not a valid directory.
Searching for source files
Found 7 source files
pyright 1.1.300
0 errors, 0 warnings, 0 informations
Completed in 1.006sec

Now pyright is just as polite as your other tools:

$ hatch run lint
cmd [1] | - ruff check .
cmd [2] | - black --quiet --check --diff .
cmd [3] | - pyright-polite
Found 8 source files
0 errors, 0 warnings, 0 informations
cmd [4] | - ssort --check --diff .
8 files would be left unchanged

Error messages are still shown (eg, if your pyright config file is invalid).

Installation

You need pyright installed (ie, available somewhere in your PATH).

See pyright's installation instructions here. Usually people install either the pyright npm or the pyright PyPI package.

$ npm install pyright  # alternatively: pip install pyright
$ pip install pyright-polite

Linux, macOS and Windows are all supported.

Usage

pyright-polite takes the same arguments as pyright.

$ pyright-polite -h
Usage: pyright-polite [options] files...
  Options:
  --createstub <IMPORT>              Create type stub file(s) for import
  --dependencies                     Emit import dependency information
  -h,--help                          Show this help message
  --ignoreexternal                   Ignore external imports for --verifytypes
  --lib                              Use library code to infer types when stubs are missing
  --level <LEVEL>                    Minimum diagnostic level (error or warning)
  --outputjson                       Output results in JSON format
  -p,--project <FILE OR DIRECTORY>   Use the configuration file at this location
  --pythonplatform <PLATFORM>        Analyze for a specific platform (Darwin, Linux, Windows)
  --pythonversion <VERSION>          Analyze for a specific version (3.3, 3.4, etc.)
  --skipunannotated                  Skip analysis of functions with no type annotations
  --stats                            Print detailed performance stats
  -t,--typeshed-path <DIRECTORY>     Use typeshed type stubs at this location
  -v,--venv-path <DIRECTORY>         Directory that contains virtual environments
  --verbose                          Emit verbose diagnostics
  --verifytypes <PACKAGE>            Verify type completeness of a py.typed package
  --version                          Print Pyright version
  --warnings                         Use exit code of 1 if warnings are reported
  -w,--watch                         Continue to run and watch for changes


  Note: pyright-polite does not filter output from `--dependencies` or `--stats`.

How does it work?

pyright-polite is hilariously over-engineered, but robust.

It aims to display everything in exactly the same format and colorisation as pyright (minus the useless messages), and takes advantage of pyright's --outputjson option when possible. It launches pyright as a subprocess and reads from both stderr and stdout using asyncio tasks, which means that --watch is also supported.

For insight into what messages get hidden, see the print_filtered method.

Isn't this a bit overkill?

Yes :rofl:

It was primarily a fun weekend project to learn asyncio.

Why is pyright so noisy?

If you're wondering why pyright has to remind us that typings is not a valid directory (among other useless messages) on literally every single launch, see pyright #4594 for what the developers have to say:

The current information output by the cli is there for a reason.

License

pyright-polite is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyright_polite-1.0.5.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

pyright_polite-1.0.5-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file pyright_polite-1.0.5.tar.gz.

File metadata

  • Download URL: pyright_polite-1.0.5.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for pyright_polite-1.0.5.tar.gz
Algorithm Hash digest
SHA256 cdccb38d2127c24a2dc243e851d5acffef7d7bc2eee9311529049ebbd87d10bc
MD5 61d4bc3085bcc64dd11193397eff79d2
BLAKE2b-256 e3d5a21c4f663d49e682240271e201301fa5b122799833c3f9ae5b3ec42f03a0

See more details on using hashes here.

File details

Details for the file pyright_polite-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for pyright_polite-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8ef2d54098b7eedcff118847fef2868536995d14bafd98d5c554588ecfd955ff
MD5 842bfedd85f516c0aa127ea71025982f
BLAKE2b-256 f04813457c11a951c03b0e97721d7e1bf61ff4d9e33181f7469ce0fbf62d77bd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page