diff options
Diffstat (limited to 'pint/facets/context/registry.py')
-rw-r--r-- | pint/facets/context/registry.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pint/facets/context/registry.py b/pint/facets/context/registry.py index 746e79c..85682d1 100644 --- a/pint/facets/context/registry.py +++ b/pint/facets/context/registry.py @@ -11,7 +11,7 @@ from __future__ import annotations import functools from collections import ChainMap from contextlib import contextmanager -from typing import Any, Callable, Generator, Generic +from typing import Any, Callable, Generator, Generic, Optional, Union from ...compat import TypeAlias from ..._typing import F, Magnitude @@ -74,7 +74,7 @@ class GenericContextRegistry( super()._register_definition_adders() self._register_adder(ContextDefinition, self.add_context) - def add_context(self, context: objects.Context | ContextDefinition) -> None: + def add_context(self, context: Union[objects.Context, ContextDefinition]) -> None: """Add a context object to the registry. The context will be accessible by its name and aliases. @@ -197,7 +197,7 @@ class GenericContextRegistry( self.define(definition) def enable_contexts( - self, *names_or_contexts: str | objects.Context, **kwargs: Any + self, *names_or_contexts: Union[str, objects.Context], **kwargs: Any ) -> None: """Enable contexts provided by name or by object. @@ -244,7 +244,7 @@ class GenericContextRegistry( self._active_ctx.insert_contexts(*contexts) self._switch_context_cache_and_units() - def disable_contexts(self, n: int | None = None) -> None: + def disable_contexts(self, n: Optional[int] = None) -> None: """Disable the last n enabled contexts. Parameters @@ -403,7 +403,7 @@ class GenericContextRegistry( return super()._convert(value, src, dst, inplace) def _get_compatible_units( - self, input_units: UnitsContainer, group_or_system: str | None = None + self, input_units: UnitsContainer, group_or_system: Optional[str] = None ): src_dim = self._get_dimensionality(input_units) |