Metadata-Version: 2.1
Name: npt-promote
Version: 0.2
Summary: Mypy plugin to add type promotions between NumPy and builtin data types.
License: MIT
Project-URL: Homepage, https://github.com/pyvista/npt-promote
Keywords: mypy,typing,numpy
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mypy
Requires-Dist: numpy>=1.21
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-mypy-plugins; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"

# npt-promote
Mypy plugin to add type promotions between NumPy and builtin data types.

The main use case for this plugin is to enable generic use of `bool`, `int` and `float`
type annotations with NumPy arrays, e.g.

``` python
import numpy as np
import numpy.typing as npt

x: npt.NDArray[float] = np.array((42.0))
```

## Installation

Dependencies:
- [mypy](https://github.com/python/mypy)
- [NumPy](https://github.com/numpy/numpy)

Install it with:

``` bash
python -m pip install npt-promote
```

Alternatively, add `npt-promote` as a project dependency wherever `mypy` is used,
e.g. as an optional dev requirement in `pyproject.toml`:

``` toml
[project.optional-dependencies]
dev = ["mypy", "npt-promote"]
```

## Usage

To enable the plugin, it must be added to your project's mypy configuration file
along with NumPy's mypy plugin. E.g. add the following to `pyproject.toml`:

``` toml
[tool.mypy]
plugins = [
  'numpy.typing.mypy_plugin',
  'npt_promote',
]
```

## pre-commit
To use the plugin with `mypy` as a `pre-commit` hook, it must be added as a
dependency, e.g. add the following to `.pre-commit-config.yaml`:
``` yaml
- repo: https://github.com/pre-commit/mirrors-mypy
  hooks:
  - id: mypy
    additional_dependencies: [
      "npt-promote"
    ]
```

## Testing

First, install `npt-promote` with dev requirements:
``` bash
python -m pip install npt-promote[dev]
```

To run the tests, execute:
``` bash
pytest
```
