Optype

Latest version: v0.9.0

Safety actively analyzes 702253 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 3

0.9.0

<!-- Release notes generated using configuration in .github/release.yml at v0.9.0 -->

Highlights

* ⚡ Faster `import optype as op` by deferring submodule imports (https://github.com/jorenham/optype/pull/251)
* ✨ New `op.io` submodule ([docs](https://github.com/jorenham/optype/blob/master/README.md#optypeio)) (https://github.com/jorenham/optype/pull/253)
* ✨ New and improved `op.Just` types ([docs](https://github.com/jorenham/optype/blob/master/README.md#just)):
- `Just[T]` - Accepts `_: T` iff. `type(_) is T`.
- `JustInt` - Accepts `_: int` and literal ints, rejects e.g. `_: bool`
- `JustFloat` - Accepts `_: float`, rejects e.g. `_: int` and `_: numpy.float64`
- `JustComplex` - Accepts `_: complex`, rejects `_: float` and `_: numpy.complex128`
- `JustBytes` - Accepts `_: bytes` and bytes-literals, rejects `_: bytearray`, `_: memoryview`, and `_: numpy.bytes_`
- `JustObject` - Accepts `_: object`, rejects everything else. Useful for annotating sentinels like `DEFAULT = object()`.
* ✨ New `op.numpy.is_array_{0,1,2,3,n}d` typeguards ([docs](https://github.com/jorenham/optype/blob/master/README.md#array-typeguards)) (https://github.com/jorenham/optype/pull/270)

Deprecations

* The `op.typing.Just*` types are deprecated in favor of `op.Just*`.

What's Changed

`optype`

* generic `optype.HasClass`: suprisingly useful! by jorenham in https://github.com/jorenham/optype/pull/257
* move `Just*` from `optype.typing` to `optype` and deprecate by jorenham in https://github.com/jorenham/optype/pull/258
* custom runtime-checkable `Just*` types by jorenham in https://github.com/jorenham/optype/pull/260
* `Just` without redundant typing hacks by jorenham in https://github.com/jorenham/optype/pull/261
* add `JustObject` by jorenham in https://github.com/jorenham/optype/pull/264
* add `JustBytes` by jorenham in https://github.com/jorenham/optype/pull/265
* change `HasFunc` and `HasWrapped` generic type params by jorenham in https://github.com/jorenham/optype/pull/267
* change `HasTypeParams` type params by jorenham in https://github.com/jorenham/optype/pull/268

`optype.numpy`

* prefer `Just{Float,Complex}` over `Just[{float,complex}]` in `optype.numpy` by jorenham in https://github.com/jorenham/optype/pull/240
* add the missing `Just` types to `onp.Any*DType` by jorenham in https://github.com/jorenham/optype/pull/243
* `optype.numpy.is_` typeguard by jorenham in https://github.com/jorenham/optype/pull/270
* split the private `op.numpy._any_dtype` module into two by jorenham in https://github.com/jorenham/optype/pull/275
* new `optype.numpy.ToDType` alias by jorenham in https://github.com/jorenham/optype/pull/276

Dependencies

* ruff 0.9.1, basedpyright 1.23.2, basedmypy 2.9.1 by jorenham in https://github.com/jorenham/optype/pull/239
* bump `basedpyright` to `1.24.0` by jorenham in https://github.com/jorenham/optype/pull/255
* bump `ruff` to `0.9.2` by jorenham in https://github.com/jorenham/optype/pull/259
* bump `numpy` to `2.2.2` (dev-only) by jorenham in https://github.com/jorenham/optype/pull/263
* bump `pre-commit` to `4.1.0` by jorenham in https://github.com/jorenham/optype/pull/271

Continuous integration

* trigger the build & publish workflow on (pre)release by jorenham in https://github.com/jorenham/optype/pull/238
* automatically label PR's by jorenham in https://github.com/jorenham/optype/pull/247
* add `CODEOWNERS` by jorenham in https://github.com/jorenham/optype/pull/248

Other Changes

* more consistent style for imports and exports by jorenham in https://github.com/jorenham/optype/pull/246
* lazy submodule imports by jorenham in https://github.com/jorenham/optype/pull/251
* `optype.io` by jorenham in https://github.com/jorenham/optype/pull/253
* stop using `__future__.annotations` and `typing.TYPE_CHECKING` by jorenham in https://github.com/jorenham/optype/pull/256
* cleaner `ruff.lint.isort` config by jorenham in https://github.com/jorenham/optype/pull/262
* cleaner private module structure by jorenham in https://github.com/jorenham/optype/pull/266
* format `pyproject.toml` by jorenham in https://github.com/jorenham/optype/pull/269
* update the auto-release changelog config by jorenham in https://github.com/jorenham/optype/pull/272
* globally ignore common inline typechecker ignores by jorenham in https://github.com/jorenham/optype/pull/273


**Full Changelog**: https://github.com/jorenham/optype/compare/v0.8.0...v0.9.0

0.8.0

<!-- Release notes generated using configuration in .github/release.yml at v0.8.0 -->

What's Changed
`optype.numpy`
* accept more valid numpy array-likes in `optype.numpy.To*{1,2,3,N}` by jorenham in https://github.com/jorenham/optype/pull/214
* `onp.Any[U]Int{DType,Array}` for `np.int_` by jorenham in https://github.com/jorenham/optype/pull/224
* include `opt.Just[{int,float,complex}]` in `onp.Any{Int,Float,Complex}{Array,DType}` by jorenham in https://github.com/jorenham/optype/pull/225
* new `onp.compat` module, and `Any` as shape-type default on `numpy<2.1` by jorenham in https://github.com/jorenham/optype/pull/226
* new `onp.Matrix` and `onp.MArray[{0,1,2,3}D]` aliases by jorenham in https://github.com/jorenham/optype/pull/228
* `onp.AnyBytes8DType` for `np.dtype("c")` by jorenham in https://github.com/jorenham/optype/pull/230
* new `onp.ToJust{Bool,Float,Complex}` aliases by jorenham in https://github.com/jorenham/optype/pull/231
* new `onp.To[Just]{Float64,Complex128}*` aliases by jorenham in https://github.com/jorenham/optype/pull/232
`optype.pickle`
* Added missed optype documentation by kam193 in https://github.com/jorenham/optype/pull/212
`optype.typing`
* add `JustFloat` and `JustComplex` to `optype.typing` by jorenham in https://github.com/jorenham/optype/pull/215
Dependencies
* migrate from `codespell` to `typos` by jorenham in https://github.com/jorenham/optype/pull/213
* bump `basedmypy` to `2.8.0` and `basedpyright` to `1.22.1` by jorenham in https://github.com/jorenham/optype/pull/218
* update development dependencies by jorenham in https://github.com/jorenham/optype/pull/223
Continuous integration
* test & typecheck all of the supported numpy versions by jorenham in https://github.com/jorenham/optype/pull/227
* PyPI trusted publishing by jorenham in https://github.com/jorenham/optype/pull/234
Other Changes
* update the security policy by jorenham in https://github.com/jorenham/optype/pull/216
* automatically generated release notes configuration by jorenham in https://github.com/jorenham/optype/pull/233

New Contributors
* kam193 made their first contribution in https://github.com/jorenham/optype/pull/212

**Full Changelog**: https://github.com/jorenham/optype/compare/v0.7.3...v0.8.0

0.7.3

Highlights

* `optype` is now on [`conda-forge`](https://anaconda.org/conda-forge/optype), thanks to lucascolley ([docs](https://github.com/jorenham/optype/blob/v0.7.3/README.md#conda))
* [`optype.numpy`] The `CanArrayND` type now optionally accepts a second shape-type argument ([docs](https://github.com/jorenham/optype/blob/v0.7.3/README.md#shape-typing-with-array))
* [`optype.numpy`] New `Array0D` and `CanArray0D` aliases for 0-dimensional numpy arrays (not scalars) ([docs](https://github.com/jorenham/optype/blob/v0.7.3/README.md#shape-typing-with-array))
* [`optype.numpy`] New `To*Strict{1,2,3}D` array-like types with "strict" shape, useful for non-overlapping shape-type overloads ([docs](https://github.com/jorenham/optype/blob/v0.7.3/README.md#array-likes))

Fixes

* Fix `ImportError` on `python >= 3.13` without `typing_extensions` installed

What's Changed
* fix license metadata by jorenham in https://github.com/jorenham/optype/pull/202
* bump `ruff` to `0.8.1` by jorenham in https://github.com/jorenham/optype/pull/203
* Conda installation instructions by jorenham in https://github.com/jorenham/optype/pull/204
* fix `typing_extensions` import on `python>=3.13` by jorenham in https://github.com/jorenham/optype/pull/205
* optional `onp.CanArrayND` shape-type param, improved shape-type compatibility by jorenham in https://github.com/jorenham/optype/pull/206
* `onp.To*Strict{1,2,3}D`: array-like aliases with strict shape-type by jorenham in https://github.com/jorenham/optype/pull/207
* fix (more) `typing_extensions` imports on `python>=3.13` by jorenham in https://github.com/jorenham/optype/pull/208
* 0-d numpy array aliases by jorenham in https://github.com/jorenham/optype/pull/209


**Full Changelog**: https://github.com/jorenham/optype/compare/v0.7.2...v0.7.3

0.7.2

Highlights

* `optype.numpy.To*3D` - Array-like aliases for 3-D array-likes ([docs](https://github.com/jorenham/optype?tab=readme-ov-file#array-likes))
* `optype.numpy.ToJustInt*` - Scalar- and array-like aliases for *just* integer array-likes, i.e. `bool` and `np.bool_` will be rejected ([docs](https://github.com/jorenham/optype?tab=readme-ov-file#array-likes))

Fixes

* 194 - workaround for a [mypy bug](https://github.com/python/mypy/issues/18184) with recursive sequences types

What's Changed
* `ruff 0.8.0` and `basedpyright 1.22.0` by jorenham in https://github.com/jorenham/optype/pull/195
* workaround for a mypy bug with recursive sequences types by jorenham in https://github.com/jorenham/optype/pull/196
* export `SequenceND` from `optype.numpy` by jorenham in https://github.com/jorenham/optype/pull/197
* 3-d aliases for arrays and array-likes in `optype.numpy` by jorenham in https://github.com/jorenham/optype/pull/198
* `ToJustInt` scalar- and array-likes in `optype.numpy` by jorenham in https://github.com/jorenham/optype/pull/199


**Full Changelog**: https://github.com/jorenham/optype/compare/v0.7.1...v0.7.2

0.7.1

What's Changed
* fix `onp.ToArray{1,2}D` names by jorenham in https://github.com/jorenham/optype/pull/193


**Full Changelog**: https://github.com/jorenham/optype/compare/v0.7.0...v0.7.1

0.7.0

Highlights

* [BREAKING] The `optype.numpy.Any*` aliases no longer accept bare scalars types
* Coercible scalar- and array-like type aliases `optype.numpy.Array{1,2,3,N}D` ([docs](https://github.com/jorenham/optype?tab=readme-ov-file#array-likes))
* The new `optype.dlpack` module with DLPack types and enums ([docs](https://github.com/jorenham/optype?tab=readme-ov-file#optypedlpack))
* Improved the readability of the `optype.numpy` types
* Experimental `Just` and `JustInt` in `optype.typing` ([docs](https://github.com/jorenham/optype?tab=readme-ov-file#just-types))

What's Changed
* development dependency updates by jorenham in https://github.com/jorenham/optype/pull/160
* native toml tox config by jorenham in https://github.com/jorenham/optype/pull/161
* switch from `poetry` to `uv` by jorenham in https://github.com/jorenham/optype/pull/162
* switch from single to double quotes for black compatibility by jorenham in https://github.com/jorenham/optype/pull/163
* enforce `ruff format` by jorenham in https://github.com/jorenham/optype/pull/164
* clean up the internal module structure by jorenham in https://github.com/jorenham/optype/pull/165
* update pre-commit hooks by pre-commit-ci in https://github.com/jorenham/optype/pull/166
* update development dependencies by jorenham in https://github.com/jorenham/optype/pull/168
* `optype.dlpack`: DLPack types and enums by jorenham in https://github.com/jorenham/optype/pull/169
* `optype.array_api` - dtypes by jorenham in https://github.com/jorenham/optype/pull/170
* Revert "`optype.array_api` - dtypes" by jorenham in https://github.com/jorenham/optype/pull/176
* PEP 735 dependency groups, and fixed mypy config by jorenham in https://github.com/jorenham/optype/pull/177
* fix `optype.numpy.CanArray` by jorenham in https://github.com/jorenham/optype/pull/178
* `optype.types.Deprecated` by jorenham in https://github.com/jorenham/optype/pull/179
* simplified `optype.numpy` dtypes by jorenham in https://github.com/jorenham/optype/pull/182
* fix and improve the `optype.numpy.Any*` docs by jorenham in https://github.com/jorenham/optype/pull/183
* improve readability of `optype.numpy` type aliases and protocols by jorenham in https://github.com/jorenham/optype/pull/184
* `optype.numpy.Array{1,2,3,N}D` aliases by jorenham in https://github.com/jorenham/optype/pull/185
* workaround a PEP 696 bug in `typing_extensions.Protocol` affecting `CanSequence` by jorenham in https://github.com/jorenham/optype/pull/186
* add SPEC 0 badge by jorenham in https://github.com/jorenham/optype/pull/187
* bump `basedpyright` to `1.21.1` (`pyright 1.1.389`) by jorenham in https://github.com/jorenham/optype/pull/188
* bump `ruff` to `0.7.4` by jorenham in https://github.com/jorenham/optype/pull/189
* experimental `Just` and `JustInt` types in `optype.typing` by jorenham in https://github.com/jorenham/optype/pull/191
* `optype.numpy.To*` coercible scalar- and array-likes by jorenham in https://github.com/jorenham/optype/pull/192

New Contributors
* pre-commit-ci made their first contribution in https://github.com/jorenham/optype/pull/166

**Full Changelog**: https://github.com/jorenham/optype/compare/v0.6.1...v0.7.0

Page 1 of 3

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.