Skip to content

Remove _DTypeLike aliases in favor of _numtype.ToDType#856

Open
Aniketsy wants to merge 3 commits intonumpy:mainfrom
Aniketsy:fix-566
Open

Remove _DTypeLike aliases in favor of _numtype.ToDType#856
Aniketsy wants to merge 3 commits intonumpy:mainfrom
Aniketsy:fix-566

Conversation

@Aniketsy
Copy link
Copy Markdown

@Aniketsy Aniketsy commented Apr 15, 2026

fixes #566

@Aniketsy Aniketsy marked this pull request as draft April 15, 2026 18:24
@Aniketsy Aniketsy marked this pull request as ready for review April 15, 2026 22:31
Comment thread src/numpy-stubs/_core/einsumfunc.pyi Outdated
_CastingSafe: TypeAlias = Literal["no", "equiv", "safe", "same_kind", "same_value"]
_CastingUnsafe: TypeAlias = Literal["unsafe"]

_ToDTypeBool: TypeAlias = _nt.ToDTypeBool
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this alias seems unnecessary

Comment thread src/numpy-stubs/_core/einsumfunc.pyi Outdated
_ToDTypeFloat: TypeAlias = _nt.ToDTypeFloat16 | _nt.ToDTypeFloat32 | _nt.ToDTypeFloat64 | _nt.ToDTypeLongDouble
_ToDTypeComplex: TypeAlias = _nt.ToDTypeComplex64 | _nt.ToDTypeComplex128 | _nt.ToDTypeCLongDouble
_ToDTypeComplex_co: TypeAlias = _ToDTypeBool | _ToDTypeUInt | _ToDTypeInt | _ToDTypeFloat | _ToDTypeComplex
_ToDTypeObject: TypeAlias = _nt.ToDTypeObject
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this alias seems unnecessary

Comment thread src/numpy-stubs/_core/umath.pyi Outdated
_CoFloat: TypeAlias = float | _nt.co_float
_CoComplex: TypeAlias = complex | _nt.co_complex

_ToDType = TypeAliasType("_ToDType", _nt._ToDType[_ScalarT], type_params=(_ScalarT,))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this alias is equivalent to _nt.ToDType, so we should just use it directly and remove this

Comment on lines +29 to +30
_ToDTypeUInt32: TypeAlias = _nt.ToDTypeUInt32
_ToDTypeUInt64: TypeAlias = _nt.ToDTypeUInt64
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for these aliases anymore now

Comment thread src/numpy-stubs/lib/recfunctions.pyi Outdated
import numpy as np
import numpy.typing as npt
from numpy._typing import _DTypeLike, _DTypeLikeVoid
from numpy._typing import _DTypeLike
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_DTypeLike could also be replaced with _nt.ToDType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove the numpy._typing._DTypeLike{} aliases in favor of _numtype.ToDType{}

2 participants