Optype

Latest version: v0.9.3

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

Scan your dependencies

Page 1 of 4

0.9.3

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

This bugfix release addresses an issue where the 2- and 3-d `optype.numpy` array-like type aliases were not assignable to their `*ND` variants, e.g.:

py
import numpy as np
import optype.numpy as onp

def fn(x: onp.ToFloatND) -> int:
return np.asarray(x).size

def f2(x: onp.ToFloat2D) -> int:
return fn(x) will no longer be rejected


This additionally works around an issue in `typing_extensions==4.13.0` that results in a `TypeError` being raised when taking the union of `typing.TypeAliasType` and `typing_extension.TypeAliasType` on (at least) Python 3.12.

What's Changed
`optype.numpy`
* update development dependencies, and more flexible pyright config by jorenham in https://github.com/jorenham/optype/pull/307
* fix `To{}(2|3)D` not being assignable to `To{}ND` by jorenham in https://github.com/jorenham/optype/pull/308
Other Changes
* prepare for next release by jorenham in https://github.com/jorenham/optype/pull/304
* bump `ruff` to `0.11.0` by jorenham in https://github.com/jorenham/optype/pull/305


**Full Changelog**: https://github.com/jorenham/optype/compare/v0.9.2...v0.9.3

0.9.2

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

What's Changed

`optype`

* mark `optype.Just*` as `final` and simplify metaclasses by jorenham in https://github.com/jorenham/optype/pull/299
* add `optype.JustDate` by jorenham in https://github.com/jorenham/optype/pull/300

`optype.numpy`

* `numpy>=2.2` fixes for array- and dtype-likes by jorenham in https://github.com/jorenham/optype/pull/301
* new `optype.numpy.random` submodule by jorenham in https://github.com/jorenham/optype/pull/302
* common numpy literal types by jorenham in https://github.com/jorenham/optype/pull/303

Dependencies

* update the dev deps by jorenham in https://github.com/jorenham/optype/pull/291
* bump `numpy` to `2.2.3` by jorenham in https://github.com/jorenham/optype/pull/292
* remove pre-commit by jorenham in https://github.com/jorenham/optype/pull/296
* update development dependencies by jorenham in https://github.com/jorenham/optype/pull/297
* bump `basedmypy` to `2.10.0` by jorenham in https://github.com/jorenham/optype/pull/298

Other Changes

* prepare for `v0.9.2` by jorenham in https://github.com/jorenham/optype/pull/289


**Full Changelog**: https://github.com/jorenham/optype/compare/v0.9.1...v0.9.2

0.9.1

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

What's Changed

`optype.numpy`
* fix longdouble dtype name literal by jorenham in https://github.com/jorenham/optype/pull/283
* remove `float80` and `complex160` from `[c]longdouble` by jorenham in https://github.com/jorenham/optype/pull/285
* add `onp.NDim0`, which, unlike `NDim`, excludes `0` by jorenham in https://github.com/jorenham/optype/pull/286
* add literal `onp.To[Just]{False,True}` aliases by jorenham in https://github.com/jorenham/optype/pull/287
* generic `onp.ToArrayStrict{1,2,3}D` by jorenham in https://github.com/jorenham/optype/pull/288

Dependencies
* Update the development dependencies by jorenham in https://github.com/jorenham/optype/pull/281
* bump `ruff` to `0.9.4` by jorenham in https://github.com/jorenham/optype/pull/284

Other Changes
* prepare for `v0.9.1` by jorenham in https://github.com/jorenham/optype/pull/277


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

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

Page 1 of 4

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.