Metadata-Version: 2.1
Name: ni-python-styleguide
Version: 0.4.2
Summary: NI's internal and external Python linter rules and plugins
Home-page: https://github.com/ni/python-styleguide
License: MIT
Author: NI
Author-email: opensource@ni.com
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: black (>=23.1)
Requires-Dist: click (>=7.1.2)
Requires-Dist: flake8 (>=5.0,<6.0); python_version >= "3.7" and python_version < "3.12"
Requires-Dist: flake8 (>=6.1,<7.0); python_version >= "3.12" and python_version < "4.0"
Requires-Dist: flake8-black (>=0.2.1)
Requires-Dist: flake8-docstrings (>=1.5.0)
Requires-Dist: flake8-import-order (>=0.18.1)
Requires-Dist: importlib-metadata (<5.0); python_version < "3.8"
Requires-Dist: isort (>=5.10)
Requires-Dist: pep8-naming (>=0.11.1)
Requires-Dist: pycodestyle (>=2.11,<3.0); python_version >= "3.12" and python_version < "4.0"
Requires-Dist: pycodestyle (>=2.9,<3.0); python_version >= "3.7" and python_version < "3.12"
Requires-Dist: toml (>=0.10.1)
Project-URL: Repository, https://github.com/ni/python-styleguide
Description-Content-Type: text/markdown

# NI Python Style Guide

![logo](https://raw.githubusercontent.com/ni/python-styleguide/main/docs/logo.svg)

---

[![PyPI version](https://badge.fury.io/py/ni-python-styleguide.svg)](https://badge.fury.io/py/ni-python-styleguide) ![Publish Package](https://github.com/ni/python-styleguide/workflows/Publish%20Package/badge.svg) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/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](https://github.com/ni/python-styleguide/tree/main/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:

```bash
pip install ni-python-styleguide
```

### Linting

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

```bash
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](https://pypi.org/project/black/) and [isort](https://pycqa.github.io/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.

```toml
# 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.

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

### Editor Integration

(This section to come!)

