Mypy plugin to add type promotions between NumPy and builtin data types.
Project description
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.
import numpy as np
import numpy.typing as npt
x: npt.NDArray[float] = np.array((42.0))
Installation
Dependencies:
Install it with:
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:
[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:
[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:
- repo: https://github.com/pre-commit/mirrors-mypy
hooks:
- id: mypy
additional_dependencies: [
"npt-promote"
]
Testing
First, install npt-promote with dev requirements:
python -m pip install npt-promote[dev]
To run the tests, execute:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file npt_promote-0.2-py3-none-any.whl.
File metadata
- Download URL: npt_promote-0.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f501cdcebf5fd98980dfa7da318300fcbef1024cd2728d416380fe43dc7f2e88
|
|
| MD5 |
3dd10459f7685c20c7da3622c404bbd2
|
|
| BLAKE2b-256 |
0e79b6c4b8021e60b5a2927a9109350b19a88eb006111a6739af92e5f56c7a96
|