diff --git a/poetry.lock b/poetry.lock index 5029325..7e81907 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1412,4 +1412,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "8f60befb298fc183823a63f1d02835395b93ece3ef563b535673cb54a0b046e4" +content-hash = "27ffc87c72375870d64e7897fb770ce43a8b64f025da7bf9b25c1d7f6f6f474c" diff --git a/pyproject.toml b/pyproject.toml index 80d100a..2d64541 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ python = "^3.9" grpcio = {version=">=1.49.0,<2.0"} protobuf = {version=">=4.21"} ni-measurement-plugin-sdk = {version=">=2.3"} +typing-extensions = ">=4.13.2" [tool.poetry.group.dev.dependencies] types-grpcio = ">=1.0" diff --git a/src/nipanel/_panel_client.py b/src/nipanel/_panel_client.py index bfcdecb..0d37bfa 100644 --- a/src/nipanel/_panel_client.py +++ b/src/nipanel/_panel_client.py @@ -4,15 +4,14 @@ import logging import threading -from typing import TypeVar, Callable +from typing import Callable, TypeVar import grpc from ni.pythonpanel.v1.python_panel_service_pb2 import OpenPanelRequest from ni.pythonpanel.v1.python_panel_service_pb2_grpc import PythonPanelServiceStub from ni_measurement_plugin_sdk_service.discovery import DiscoveryClient from ni_measurement_plugin_sdk_service.grpc.channelpool import GrpcChannelPool - -from nipanel._typing import ParamSpec +from typing_extensions import ParamSpec _P = ParamSpec("_P") _T = TypeVar("_T") diff --git a/src/nipanel/_typing.py b/src/nipanel/_typing.py deleted file mode 100644 index 877f1ff..0000000 --- a/src/nipanel/_typing.py +++ /dev/null @@ -1,133 +0,0 @@ -"""Version-specific compatibility shims for the standard `typing` module. - -For `typing` symbols that require Python 3.10 or later, this submodule redirects to the standard -`typing` module (when appropriate), the `typing_extensions` package, or provides a minimial stub -implementation for run time. This allows us to use new typing features without littering the rest of -our code with conditionals or making our Python packages depend on `typing_extenions` at run time. - -For `typing` symbols that are supported in Python 3.9, you do not need this submodule. Import these -symbols directly from the standard `typing` module. - -This submodule is vendored in multiple packages (nitypes, nipanel, etc.) to avoid compatibility -breakage when upgrading these packages. - -Do not add project-specific types to this submodule. - -Many of these symbosl are references to `None` at run time. Clients of this submodule should use -`from __future__ import annotations` to avoid parsing type hints at run time. -""" - -from __future__ import annotations - -import sys -from typing import TYPE_CHECKING - -if sys.version_info >= (3, 10): - from typing import ( - Concatenate, - ParamSpec, - ParamSpecArgs, - ParamSpecKwargs, - TypeAlias, - TypeGuard, - ) -elif TYPE_CHECKING: - from typing_extensions import ( - Concatenate, - ParamSpec, - ParamSpecArgs, - ParamSpecKwargs, - TypeAlias, - TypeGuard, - ) -else: - Concatenate = ParamSpecArgs = ParamSpecKwargs = TypeAlias = TypeGuard = None - - def ParamSpec( # noqa: D103, N802 - Missing docstring, wrong case - name, *, bound=None, covariant=False, contravariant=False - ): - return None - - -if sys.version_info >= (3, 11): - from typing import ( - LiteralString, - Never, - NotRequired, - Required, - Self, - TypeVarTuple, - Unpack, - assert_never, - assert_type, - reveal_type, - ) -elif TYPE_CHECKING: - from typing_extensions import ( - LiteralString, - Never, - NotRequired, - Required, - Self, - TypeVarTuple, - Unpack, - assert_never, - assert_type, - reveal_type, - ) -else: - LiteralString = Never = NotRequired = Required = Self = Unpack = None - - def assert_never(arg, /): # noqa: D103 - Missing docstring in public function - pass - - def assert_type(val, typ, /): # noqa: D103 - Missing docstring in public function - pass - - def reveal_type(obj, /): # noqa: D103 - Missing docstring in public function - pass - - def TypeVarTuple(name): # noqa: D103, N802 - Missing docstring, wrong case - return None - - -if sys.version_info >= (3, 12): - from typing import TypeAliasType, override -elif TYPE_CHECKING: - from typing_extensions import TypeAliasType, override -else: - TypeAliasType = None - - def override(arg, /): # noqa: D103 - Missing docstring in public function - return arg - - -if sys.version_info >= (3, 13): - from typing import ReadOnly, TypeIs -elif TYPE_CHECKING: - from typing_extensions import ReadOnly, TypeIs -else: - ReadOnly = TypeIs = None - -__all__ = [ - "assert_never", - "assert_type", - "Concatenate", - "LiteralString", - "Never", - "NotRequired", - "override", - "ParamSpec", - "ParamSpecArgs", - "ParamSpecKwargs", - "ReadOnly", - "Required", - "reveal_type", - "Self", - "TypeAlias", - "TypeAliasType", - "TypeGuard", - "TypeIs", - "TypeVarTuple", - "Unpack", -]