Skip to content

Commit 09a37a2

Browse files
committed
mypy
1 parent 453564f commit 09a37a2

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/example_fgen_basic/error_v/creation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
except (ModuleNotFoundError, ImportError) as exc: # pragma: no cover
2020
raise CompiledExtensionNotFoundError("example_fgen_basic._lib.m_error_v_w") from exc
2121
try:
22-
from example_fgen_basic._lib import ( # type: ignore
23-
m_error_v_creation_w,
24-
)
22+
from example_fgen_basic._lib import m_error_v_creation_w
2523
except (ModuleNotFoundError, ImportError) as exc: # pragma: no cover
2624
raise CompiledExtensionNotFoundError(
2725
"example_fgen_basic._lib.m_error_v_creation_w"

src/example_fgen_basic/error_v/passing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
except (ModuleNotFoundError, ImportError) as exc: # pragma: no cover
2222
raise CompiledExtensionNotFoundError("example_fgen_basic._lib.m_error_v_w") from exc
2323
try:
24-
from example_fgen_basic._lib import ( # type: ignore
25-
m_error_v_passing_w,
26-
)
24+
from example_fgen_basic._lib import m_error_v_passing_w
2725
except (ModuleNotFoundError, ImportError) as exc: # pragma: no cover
2826
raise CompiledExtensionNotFoundError(
2927
"example_fgen_basic._lib.m_error_v_passing_w"
@@ -84,7 +82,9 @@ def pass_errors(invs: tuple[ErrorV, ...]) -> NP_ARRAY_OF_BOOL:
8482
)
8583

8684
# Convert the result to boolean
87-
res_raw = m_error_v_passing_w.pass_errors(instance_indexes, n=instance_indexes.size)
85+
res_raw: NP_ARRAY_OF_INT = m_error_v_passing_w.pass_errors(
86+
instance_indexes, n=instance_indexes.size
87+
)
8888
res = res_raw.astype(bool)
8989

9090
# Tell Fortran to finalise the objects on the Fortran side

src/example_fgen_basic/typing.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@
77
from typing import TYPE_CHECKING
88

99
if TYPE_CHECKING:
10-
from typing import Any, TypeAlias, Union
10+
from typing import Union
1111

1212
import numpy as np
1313
import numpy.typing as npt
14+
from typing_extensions import Any, TypeAlias
1415

15-
NP_ARRAY_OF_INT: TypeAlias = npt.NDArray[np.integer]
16+
NP_ARRAY_OF_INT: TypeAlias = npt.NDArray[np.integer[Any]]
1617
"""
1718
Type alias for an array of numpy int
1819
"""
1920

20-
NP_ARRAY_OF_FLOAT: TypeAlias = npt.NDArray[np.floating]
21+
NP_ARRAY_OF_FLOAT: TypeAlias = npt.NDArray[np.floating[Any]]
2122
"""
2223
Type alias for an array of numpy floats
2324
"""
2425

25-
NP_FLOAT_OR_INT: TypeAlias = Union[np.floating, np.integer]
26+
NP_FLOAT_OR_INT: TypeAlias = Union[np.floating[Any], np.integer[Any]]
2627
"""
2728
Type alias for a numpy float or int (not complex)
2829
"""

0 commit comments

Comments
 (0)