Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TYP: type annotations #135

Merged
merged 12 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions array_api_strict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

"""

from types import ModuleType

__all__ = []

# Warning: __array_api_version__ could change globally with
Expand Down Expand Up @@ -325,12 +327,16 @@
ArrayAPIStrictFlags,
)

__all__ += ['set_array_api_strict_flags', 'get_array_api_strict_flags', 'reset_array_api_strict_flags', 'ArrayAPIStrictFlags']
__all__ += [
'set_array_api_strict_flags',
'get_array_api_strict_flags',
'reset_array_api_strict_flags',
'ArrayAPIStrictFlags',
'__version__',
]

try:
from . import _version
__version__ = _version.__version__
del _version
from ._version import __version__ # type: ignore[import-not-found,unused-ignore]
except ImportError:
__version__ = "unknown"

Expand All @@ -340,7 +346,7 @@
# use __getattr__. Note that linalg and fft are dynamically added and removed
# from __all__ in set_array_api_strict_flags.

def __getattr__(name):
def __getattr__(name: str) -> ModuleType:
if name in ['linalg', 'fft']:
if name in get_array_api_strict_flags()['enabled_extensions']:
if name == 'linalg':
Expand Down
Loading
Loading