|
1 | 1 | <h1 align="center">scipy-stubs</h1> |
2 | 2 |
|
3 | 3 | <p align="center"> |
4 | | - Typing stubs for <a href="https://github.com/scipy/scipy">SciPy</a>. |
| 4 | + Precise type hints for <i>all</i> of <a href="https://github.com/scipy/scipy">SciPy</a>. |
5 | 5 | </p> |
6 | 6 |
|
7 | 7 | <p align="center"> |
|
65 | 65 |
|
66 | 66 | ______________________________________________________________________ |
67 | 67 |
|
| 68 | +## Highlights |
| 69 | + |
| 70 | +- Works out-of-the-box |
| 71 | + - all that's needed is to [install `scipy-stubs`](#installation) |
| 72 | + - does not require a `mypy` plugin or other configuration |
| 73 | + - available on [PyPI](https://pypi.org/project/scipy-stubs/) and [conda-forge](https://anaconda.org/conda-forge/scipy-stubs) |
| 74 | +- Improves IDE suggestions and autocompletion |
| 75 | + - ... even if you don't use static typing in your code |
| 76 | + - no additional plugins required |
| 77 | +- 0% runtime overhead |
| 78 | + - not even a single import is required |
| 79 | +- 100% coverage of the [public SciPy API](https://docs.scipy.org/doc/scipy-1.14.1/reference/index.html) |
| 80 | + - also covers most of the private API |
| 81 | +- Precise type-hinting of dtypes and [shape-types](https://github.com/numpy/numpy/issues/16544) |
| 82 | + - works with all "array-likes" and "dtype-likes" |
| 83 | + - many of the functions that return an array are *shape-typed* |
| 84 | + - shape-typing is optional: all functions still accept arrays with unknown shape-type |
| 85 | +- Type-checker agnostic |
| 86 | + - works with at least [`mypy`](https://github.com/KotlinIsland/basedmypy), |
| 87 | + [`pyright`](https://github.com/DetachHead/basedpyright)/pylance and [`ruff`](https://github.com/astral-sh/ruff) |
| 88 | + - ... even in the strict mode |
| 89 | + - compatible with the [Python Typing Spec](https://typing.readthedocs.io/en/latest/spec/index.html) |
| 90 | +- [SPEC 0](https://scientific-python.org/specs/spec-0000/) compliant |
| 91 | + - Supports Python β₯ 3.10 |
| 92 | + - Supports NumPy β₯ 1.24 |
| 93 | + |
68 | 94 | ## Installation |
69 | 95 |
|
70 | 96 | <table> |
@@ -93,12 +119,40 @@ conda install conda-forge::scipy-stubs |
93 | 119 |
|
94 | 120 | </table> |
95 | 121 |
|
| 122 | +## Supported static type-checkers |
| 123 | + |
| 124 | +1. [`basedpyright`](https://github.com/DetachHead/basedpyright) (recommended) |
| 125 | +1. [`basedmypy`](https://github.com/KotlinIsland/basedmypy) |
| 126 | +1. [`pyright`](https://pyright.readthedocs.io/en/latest/index.html) |
| 127 | +1. [`mypy`](https://mypy.readthedocs.io/en/stable/index.html) (not recommended, see [erictraut/mypy_issues](https://github.com/erictraut/mypy_issues)) |
| 128 | + |
| 129 | +For validation and testing, `scipy-stubs` primarily uses [`basedmypy`](https://github.com/KotlinIsland/basedmypy) (a `mypy` fork) |
| 130 | +and [`basedpyright`](https://github.com/DetachHead/basedpyright) (a `pyright` fork). |
| 131 | +They are in generally stricter than `mypy` and `pyright`, so you can assume compatibility with `mypy` and `pyright` as well. |
| 132 | +But if you find that this isn't the case, then don't hesitate to open an issue or submit a pull request. |
| 133 | + |
| 134 | +## Versioning and requirements |
| 135 | + |
| 136 | +The versioning scheme of `scipy-stubs` includes the compatible `scipy` version as `{scipy_version}.{stubs_version}`. |
| 137 | +Even though `scipy-stubs` doesn't enforce an upper bound on the `scipy` version, later `scipy` versions aren't guaranteed to be |
| 138 | +fully compatible. |
| 139 | + |
| 140 | +The supported range of `numpy` versions are specified in [`SPEC 0`](https://scientific-python.org/specs/spec-0000/), which |
| 141 | +`scipy-stubs` aims to follow as close as feasible. |
| 142 | + |
| 143 | +Currently, `scipy-stubs` has one required dependency: [`optype`](https://github.com/jorenham/optype). |
| 144 | +This is essential for `scipy-stubs` to work properly, as it relies heavily on it for annotating (shaped) array-likes, |
| 145 | +scalar-likes, shape-typing in general, and much more. |
| 146 | +At the moment, `scipy-stubs` requires the latest version `optype`. |
| 147 | + |
| 148 | +The exact version requirements are specified in the [`pyproject.toml`](pyproject.toml). |
| 149 | + |
96 | 150 | ## `scipy` coverage |
97 | 151 |
|
98 | 152 | The entire public API of `scipy` is **fully annotated** and **verifiably valid**. |
99 | 153 | For the most part, this can also be said about `scipy`'s private API and other internal machinery. |
100 | 154 |
|
101 | | -However, a small portion uses `Untyped` (and alias of `Any`) as "placeholder annotations". |
| 155 | +However, a small portion uses `Untyped` (an alias of `Any`) as "placeholder annotations". |
102 | 156 | In those cases static type-checkers won't do any type-checking, and won't bother you with errors or warnings. |
103 | 157 |
|
104 | 158 | The following table shows the (subjective) proportion of `scipy-stubs` that is(n't) annotated with `Untyped`, ranging |
@@ -126,34 +180,6 @@ from π (100% `Untyped`) to π (0% `Untyped`). |
126 | 180 | | `stats` | βοΈ | βοΈ | βοΈ | βοΈ | π | |
127 | 181 | | *`_lib`* | βοΈ | βοΈ | βοΈ | βοΈ | π | |
128 | 182 |
|
129 | | -## Supported static type-checkers |
130 | | - |
131 | | -1. [`basedpyright`](https://github.com/DetachHead/basedpyright) (recommended) |
132 | | -1. [`basedmypy`](https://github.com/KotlinIsland/basedmypy) |
133 | | -1. [`pyright`](https://pyright.readthedocs.io/en/latest/index.html) |
134 | | -1. [`mypy`](https://mypy.readthedocs.io/en/stable/index.html) (not recommended, see [erictraut/mypy_issues](https://github.com/erictraut/mypy_issues)) |
135 | | - |
136 | | -For validation and testing, `scipy-stubs` primarily uses [`basedmypy`](https://github.com/KotlinIsland/basedmypy) (a `mypy` fork) |
137 | | -and [`basedpyright`](https://github.com/DetachHead/basedpyright) (a `pyright` fork). |
138 | | -They are in generally stricter than `mypy` and `pyright`, so you can assume compatibility with `mypy` and `pyright` as well. |
139 | | -But if you find that this isn't the case, then don't hesitate to open an issue or submit a pull request. |
140 | | - |
141 | | -## Versioning and requirements |
142 | | - |
143 | | -The versioning scheme of `scipy-stubs` includes the compatible `scipy` version as `{scipy_version}.{stubs_version}`. |
144 | | -Even though `scipy-stubs` doesn't enforce an upper bound on the `scipy` version, later `scipy` versions aren't guaranteed to be |
145 | | -fully compatible. |
146 | | - |
147 | | -The supported range of `numpy` versions are specified in [`SPEC 0`](https://scientific-python.org/specs/spec-0000/), which |
148 | | -`scipy-stubs` aims to follow as close as feasible. |
149 | | - |
150 | | -Currently, `scipy-stubs` has one required dependency: [`optype`](https://github.com/jorenham/optype). |
151 | | -This is essential for `scipy-stubs` to work properly, as it relies heavily on it for annotating (shaped) array-likes, |
152 | | -scalar-likes, shape-typing in general, and much more. |
153 | | -At the moment, `scipy-stubs` requires the latest version `optype`. |
154 | | - |
155 | | -The exact version requirements are specified in the [`pyproject.toml`](pyproject.toml). |
156 | | - |
157 | 183 | ## See also |
158 | 184 |
|
159 | 185 | - [scipy/scipy#21614](https://github.com/scipy/scipy/issues/21614): On why `scipy-stubs` is a separate package, and not part of |
|
0 commit comments