Skip to main content

NI's internal and external Python linter rules and plugins

Project description

NI Python Style Guide

logo


PyPI version Publish Package Code style: black

Welcome to NI's internal and external Python conventions and enforcement tooling.

Written Conventions

Our written conventions can be found at https://ni.github.io/python-styleguide/.

Their source is in docs/Coding-Conventions.md.

NOTE: Using the GitHub Pages link is preferable to a GitHub /blob link.

Enforcement tooling

As a tool, ni-python-styleguide is installed like any other script:

pip install ni-python-styleguide

Linting

To lint, just run the lint subcommand (from within the project root, or lower):

ni-python-styleguide lint
# or
ni-python-styleguide lint ./dir/
# or
ni-python-styleguide lint module.py

The rules enforced are all rules documented in the written convention, which are marked as enforced.

Configuration

ni-python-styleguide aims to keep the configuration to a bare minimum (none wherever possible). However there are some situations you might need to configure the tool.

Fix

ni-python-styleguide has a subcommand fix which will run black and isort.

Additionally, you can run fix with the --aggressive option and it will add acknowledgements (# noqa) for the remaining linting errors it cannot fix, in addition to running black and isort.

When using setup.py

If you're using setup.py, you'll need to set your app's import names for import sorting.

# pyproject.toml
[tool.ni-python-styleguide]
application-import-names = "<app_name>"

Formatting

ni-python-styleguide in the future will have a format command which we intend to fix as many lint issues as possible.

Until then you'll want to set the following to get black formatting as the styleguide expects.

# pyproject.toml
[tool.black]
line-length = 100

Editor Integration

(This section to come!)

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

ni_python_styleguide-0.4.8.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ni_python_styleguide-0.4.8-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file ni_python_styleguide-0.4.8.tar.gz.

File metadata

  • Download URL: ni_python_styleguide-0.4.8.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ni_python_styleguide-0.4.8.tar.gz
Algorithm Hash digest
SHA256 f3434d14cc9838613171fe26faccc396a4a8b2f960e139fc92de9bf636f8ba51
MD5 2eadfdaf90d4d0f4cbfa3eedd2d71e3b
BLAKE2b-256 83aafaa89c679c78fc0d9fab0995e334f45f8f23cc7cb2d5539166094e116b84

See more details on using hashes here.

Provenance

The following attestation bundles were made for ni_python_styleguide-0.4.8.tar.gz:

Publisher: Publish-Package.yml on ni/python-styleguide

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ni_python_styleguide-0.4.8-py3-none-any.whl.

File metadata

File hashes

Hashes for ni_python_styleguide-0.4.8-py3-none-any.whl
Algorithm Hash digest
SHA256 dbbf0fc3692f7d71008ae9cd0d01c93dbf21085e0de2f0068dcd16addb573546
MD5 3dbb9f39cd87320d15ef9810fbfa3f43
BLAKE2b-256 f940ead9fa11e635eaed9c5d5c72c936d8fbe3f26af31d90fff55cc6d4434704

See more details on using hashes here.

Provenance

The following attestation bundles were made for ni_python_styleguide-0.4.8-py3-none-any.whl:

Publisher: Publish-Package.yml on ni/python-styleguide

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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