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.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

ni_python_styleguide-0.4.2-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ni_python_styleguide-0.4.2.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.18 Linux/6.2.0-1012-azure

File hashes

Hashes for ni_python_styleguide-0.4.2.tar.gz
Algorithm Hash digest
SHA256 ff1414d66a190303bd26a8bacf5cf606f3aa562818ad3a72999758f81e96718e
MD5 61cb8c44379e2c0b5ac60b9a89117145
BLAKE2b-256 43b3dd549a368a3fcbb16ae2a7e848fb3d980bf3a888a67266d0b93cf1a18ab1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ni_python_styleguide-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2bc9bd5dd1cf4d1ac0b30d9e0858a8e672f9abf5c8aca8459666db6d15b30f3c
MD5 4e2bbbc3529b00e8f060ba5ca207222e
BLAKE2b-256 dbd97e2f82fd0c87026c34517b187cca077da1f131ec13cecb47e13b760cce71

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