Skip to content

Commit d176d53

Browse files
committed
🏷️ fix stubtest errors in lib._iotools
1 parent 4929497 commit d176d53

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

.mypyignore-todo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ numpy._pyinstaller.hook-numpy
1515
numpy.ctypeslib._ctypeslib
1616
numpy.fft.helper
1717

18-
numpy.lib._iotools.NameValidator.defaultdeletechars
1918
numpy.lib.format.open_memmap
2019
numpy.lib.format.read_array(_header_(1|2)_0)?
2120
numpy.lib.mixins.NDArrayOperatorsMixin.__array_ufunc__

src/numpy-stubs/lib/_iotools.pyi

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from collections.abc import Callable, Iterable, Sequence
2-
from typing import Any, ClassVar, Final, Literal, TypedDict, overload, type_check_only
1+
from collections.abc import Callable, Iterable
2+
from typing import Any, ClassVar, Final, Literal as L, TypedDict, overload, type_check_only
33
from typing_extensions import TypeVar, Unpack
44

55
import numpy as np
@@ -11,7 +11,7 @@ _T = TypeVar("_T")
1111
class _ValidationKwargs(TypedDict, total=False):
1212
excludelist: Iterable[str] | None
1313
deletechars: Iterable[str] | None
14-
case_sensitive: Literal["upper", "lower"] | bool | None
14+
case_sensitive: L["upper", "lower"] | bool | None
1515
replace_space: str
1616

1717
###
@@ -39,8 +39,8 @@ class LineSplitter:
3939
def autostrip(self, /, method: Callable[[_T], Iterable[str]]) -> Callable[[_T], list[str]]: ...
4040

4141
class NameValidator:
42-
defaultexcludelist: ClassVar[Sequence[str]]
43-
defaultdeletechars: ClassVar[Sequence[str]]
42+
defaultexcludelist: ClassVar[list[L["return", "file", "print"]]]
43+
defaultdeletechars: ClassVar[set[str]]
4444
excludelist: list[str]
4545
deletechars: set[str]
4646
case_converter: Callable[[str], str]
@@ -51,7 +51,7 @@ class NameValidator:
5151
/,
5252
excludelist: Iterable[str] | None = None,
5353
deletechars: Iterable[str] | None = None,
54-
case_sensitive: Literal["upper", "lower"] | bool | None = None,
54+
case_sensitive: L["upper", "lower"] | bool | None = None,
5555
replace_space: str = "_",
5656
) -> None: ...
5757
def __call__(self, /, names: Iterable[str], defaultfmt: str = "f%i", nbfields: int | None = None) -> tuple[str, ...]: ...
@@ -90,16 +90,20 @@ class StringConverter:
9090
def upgrade_mapper(cls, func: Callable[[str], Any], default: object | None = None) -> None: ...
9191

9292
@overload
93-
def str2bool(value: Literal["false", "False", "FALSE"]) -> Literal[False]: ...
93+
def str2bool(value: L["false", "False", "FALSE"]) -> L[False]: ...
9494
@overload
95-
def str2bool(value: Literal["true", "True", "TRUE"]) -> Literal[True]: ...
95+
def str2bool(value: L["true", "True", "TRUE"]) -> L[True]: ...
9696

9797
#
9898
def has_nested_fields(ndtype: np.dtype[np.void]) -> bool: ...
99+
100+
#
99101
def flatten_dtype(
100102
ndtype: np.dtype[np.void],
101103
flatten_base: bool = False,
102104
) -> type[np.dtype[np.bool | np.number | np.character | np.object_ | np.datetime64 | np.timedelta64]]: ...
105+
106+
#
103107
def easy_dtype(
104108
ndtype: npt.DTypeLike,
105109
names: Iterable[str] | None = None,

0 commit comments

Comments
 (0)