diff --git a/dltype/_lib/_core.py b/dltype/_lib/_core.py index 368eede..8b5b08b 100644 --- a/dltype/_lib/_core.py +++ b/dltype/_lib/_core.py @@ -4,7 +4,6 @@ import inspect import itertools -import logging import warnings from functools import lru_cache, wraps from typing import ( @@ -31,6 +30,7 @@ _dltype_context, _dtypes, _errors, + _log_utils, _tensor_type_base, ) @@ -38,7 +38,7 @@ from collections.abc import Callable -_logger: Final = logging.getLogger(__name__) +_logger: Final = _log_utils.get_logger(__name__) P = ParamSpec("P") R = TypeVar("R") diff --git a/dltype/_lib/_dltype_context.py b/dltype/_lib/_dltype_context.py index 67d96a6..32f7e3e 100644 --- a/dltype/_lib/_dltype_context.py +++ b/dltype/_lib/_dltype_context.py @@ -2,15 +2,14 @@ from __future__ import annotations -import logging import time import warnings from collections import deque from typing import Any, Final, NamedTuple, TypeAlias, cast -from dltype._lib import _constants, _dtypes, _errors, _parser, _tensor_type_base +from dltype._lib import _constants, _dtypes, _errors, _log_utils, _parser, _tensor_type_base -_logger: Final = logging.getLogger(__name__) +_logger: Final = _log_utils.get_logger(__name__) EvaluatedDimensionT: TypeAlias = dict[str, int] diff --git a/dltype/_lib/_log_utils.py b/dltype/_lib/_log_utils.py new file mode 100644 index 0000000..48b956e --- /dev/null +++ b/dltype/_lib/_log_utils.py @@ -0,0 +1,31 @@ +"""Utilities for logging in the dltype library.""" + +import logging +import typing + +from dltype._lib import _constants + + +class DummyLogger: + def debug(self, *args: typing.Any) -> None: # noqa: ANN401 + pass + + def info(self, *args: typing.Any) -> None: # noqa: ANN401 + pass + + def warning(self, *args: typing.Any) -> None: # noqa: ANN401 + pass + + def error(self, *args: typing.Any) -> None: # noqa: ANN401 + pass + + def exception(self, *args: typing.Any) -> None: # noqa: ANN401 + pass + + +def get_logger(name: str) -> logging.Logger | DummyLogger: + if _constants.GLOBAL_DISABLE: + return DummyLogger() + if not _constants.DEBUG_MODE: + return DummyLogger() + return logging.getLogger(name) diff --git a/dltype/_lib/_parser.py b/dltype/_lib/_parser.py index fb2e50b..5682dbf 100644 --- a/dltype/_lib/_parser.py +++ b/dltype/_lib/_parser.py @@ -3,14 +3,15 @@ from __future__ import annotations import enum -import logging import math import re import typing from typing_extensions import override -_logger: typing.Final = logging.getLogger(__name__) +from dltype._lib import _log_utils + +_logger: typing.Final = _log_utils.get_logger(__name__) class _DLTypeSpecifier(enum.Enum): diff --git a/dltype/_lib/_tensor_type_base.py b/dltype/_lib/_tensor_type_base.py index 039dc9b..f120e70 100644 --- a/dltype/_lib/_tensor_type_base.py +++ b/dltype/_lib/_tensor_type_base.py @@ -15,9 +15,7 @@ _parser, _symbolic_expressions, ) -from dltype._lib import ( - _dependency_utilities as _deps, -) +from dltype._lib import _dependency_utilities as _deps if typing.TYPE_CHECKING: from pydantic import GetCoreSchemaHandler, ValidationInfo diff --git a/pyproject.toml b/pyproject.toml index 66aa862..06eeddd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ license-files = ["LICENSE"] name = "dltype" readme = "README.md" requires-python = ">=3.10" -version = "0.11.0" +version = "0.12.0" [project.optional-dependencies] jax = ["jax>=0.6.2"] diff --git a/uv.lock b/uv.lock index 13a69c4..010261a 100644 --- a/uv.lock +++ b/uv.lock @@ -158,7 +158,7 @@ wheels = [ [[package]] name = "dltype" -version = "0.11.0" +version = "0.12.0" source = { virtual = "." } dependencies = [ { name = "pydantic" }, @@ -1435,10 +1435,10 @@ dependencies = [ { name = "typing-extensions" }, ] wheels = [ - { url = "https://files.pythonhosted.org/packages/e3/ea/304cf7afb744aa626fa9855245526484ee55aba610d9973a0521c552a843/torch-2.10.0-1-cp310-none-macosx_11_0_arm64.whl", hash = "sha256:c37fc46eedd9175f9c81814cc47308f1b42cfe4987e532d4b423d23852f2bf63", size = 79411450, upload-time = "2026-02-06T17:37:35.75Z" }, - { url = "https://files.pythonhosted.org/packages/25/d8/9e6b8e7df981a1e3ea3907fd5a74673e791da483e8c307f0b6ff012626d0/torch-2.10.0-1-cp311-none-macosx_11_0_arm64.whl", hash = "sha256:f699f31a236a677b3118bc0a3ef3d89c0c29b5ec0b20f4c4bf0b110378487464", size = 79423460, upload-time = "2026-02-06T17:37:39.657Z" }, - { url = "https://files.pythonhosted.org/packages/c9/2f/0b295dd8d199ef71e6f176f576473d645d41357b7b8aa978cc6b042575df/torch-2.10.0-1-cp312-none-macosx_11_0_arm64.whl", hash = "sha256:6abb224c2b6e9e27b592a1c0015c33a504b00a0e0938f1499f7f514e9b7bfb5c", size = 79498197, upload-time = "2026-02-06T17:37:27.627Z" }, - { url = "https://files.pythonhosted.org/packages/a4/1b/af5fccb50c341bd69dc016769503cb0857c1423fbe9343410dfeb65240f2/torch-2.10.0-1-cp313-none-macosx_11_0_arm64.whl", hash = "sha256:7350f6652dfd761f11f9ecb590bfe95b573e2961f7a242eccb3c8e78348d26fe", size = 79498248, upload-time = "2026-02-06T17:37:31.982Z" }, + { url = "https://files.pythonhosted.org/packages/5b/30/bfebdd8ec77db9a79775121789992d6b3b75ee5494971294d7b4b7c999bc/torch-2.10.0-2-cp310-none-macosx_11_0_arm64.whl", hash = "sha256:2b980edd8d7c0a68c4e951ee1856334a43193f98730d97408fbd148c1a933313", size = 79411457, upload-time = "2026-02-10T21:44:59.189Z" }, + { url = "https://files.pythonhosted.org/packages/0f/8b/4b61d6e13f7108f36910df9ab4b58fd389cc2520d54d81b88660804aad99/torch-2.10.0-2-cp311-none-macosx_11_0_arm64.whl", hash = "sha256:418997cb02d0a0f1497cf6a09f63166f9f5df9f3e16c8a716ab76a72127c714f", size = 79423467, upload-time = "2026-02-10T21:44:48.711Z" }, + { url = "https://files.pythonhosted.org/packages/d3/54/a2ba279afcca44bbd320d4e73675b282fcee3d81400ea1b53934efca6462/torch-2.10.0-2-cp312-none-macosx_11_0_arm64.whl", hash = "sha256:13ec4add8c3faaed8d13e0574f5cd4a323c11655546f91fbe6afa77b57423574", size = 79498202, upload-time = "2026-02-10T21:44:52.603Z" }, + { url = "https://files.pythonhosted.org/packages/ec/23/2c9fe0c9c27f7f6cb865abcea8a4568f29f00acaeadfc6a37f6801f84cb4/torch-2.10.0-2-cp313-none-macosx_11_0_arm64.whl", hash = "sha256:e521c9f030a3774ed770a9c011751fb47c4d12029a3d6522116e48431f2ff89e", size = 79498254, upload-time = "2026-02-10T21:44:44.095Z" }, { url = "https://files.pythonhosted.org/packages/0c/1a/c61f36cfd446170ec27b3a4984f072fd06dab6b5d7ce27e11adb35d6c838/torch-2.10.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:5276fa790a666ee8becaffff8acb711922252521b28fbce5db7db5cf9cb2026d", size = 145992962, upload-time = "2026-01-21T16:24:14.04Z" }, { url = "https://files.pythonhosted.org/packages/b5/60/6662535354191e2d1555296045b63e4279e5a9dbad49acf55a5d38655a39/torch-2.10.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:aaf663927bcd490ae971469a624c322202a2a1e68936eb952535ca4cd3b90444", size = 915599237, upload-time = "2026-01-21T16:23:25.497Z" }, { url = "https://files.pythonhosted.org/packages/40/b8/66bbe96f0d79be2b5c697b2e0b187ed792a15c6c4b8904613454651db848/torch-2.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:a4be6a2a190b32ff5c8002a0977a25ea60e64f7ba46b1be37093c141d9c49aeb", size = 113720931, upload-time = "2026-01-21T16:24:23.743Z" },