π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
refactor: import Self, ParamSpec, TypedDict and NotRequired from typing (#4328)
Dmytro Mishkina5df16b1b62f
diff --git a/kornia/augmentation/auto/operations/base.py b/kornia/augmentation/auto/operations/base.pyindex 844fee4a5..82c75f63b 100644--- a/kornia/augmentation/auto/operations/base.py+++ b/kornia/augmentation/auto/operations/base.py@@ -15,12 +15,11 @@# limitations under the License.#-from typing import Callable, Dict, List, Optional, Tuple, TypeVar+from typing import Callable, Dict, List, Optional, Self, Tuple, TypeVarimport torchfrom torch import nnfrom torch.distributions import Bernoulli, RelaxedBernoulli-from typing_extensions import Selffrom kornia.augmentation.base import _AugmentationBasediff --git a/kornia/augmentation/container/ops.py b/kornia/augmentation/container/ops.pyindex 31d3eab63..950b4749c 100644--- a/kornia/augmentation/container/ops.py+++ b/kornia/augmentation/container/ops.py@@ -17,11 +17,10 @@import copyfrom abc import ABCMeta, abstractmethod-from typing import Any, Callable, Dict, Generic, List, Optional, Type, TypeVar, Union+from typing import Any, Callable, Dict, Generic, List, Optional, ParamSpec, Type, TypeVar, Unionimport torchfrom torch import nn-from typing_extensions import ParamSpecimport kornia.augmentation as Kfrom kornia.augmentation.base import _AugmentationBasediff --git a/kornia/feature/adalam/core.py b/kornia/feature/adalam/core.pyindex c9bab83da..fb900d5a8 100644--- a/kornia/feature/adalam/core.py+++ b/kornia/feature/adalam/core.py@@ -16,10 +16,9 @@#import math-from typing import Optional, Tuple, Union+from typing import NotRequired, Optional, Tuple, TypedDict, Unionimport torch-from typing_extensions import NotRequired, TypedDictfrom .ransac import ransacfrom .utils import dist_matrix, orientation_diffdiff --git a/kornia/feature/keynet.py b/kornia/feature/keynet.pyindex 8e4280656..4511d0a4b 100644--- a/kornia/feature/keynet.py+++ b/kornia/feature/keynet.py@@ -15,12 +15,11 @@# limitations under the License.#-from typing import List, Optional+from typing import List, Optional, TypedDictimport torchimport torch.nn.functional as Ffrom torch import nn-from typing_extensions import TypedDictfrom kornia.core.download import hf_url, load_state_dict_from_urlfrom kornia.filters import SpatialGradientdiff --git a/kornia/feature/scale_space_detector.py b/kornia/feature/scale_space_detector.pyindex 622937804..e3ad31753 100644--- a/kornia/feature/scale_space_detector.py+++ b/kornia/feature/scale_space_detector.py@@ -17,12 +17,11 @@import mathfrom contextlib import nullcontext-from typing import ContextManager, List, Optional, Tuple, Union+from typing import ContextManager, List, Optional, Tuple, TypedDict, Unionimport torchimport torch.nn.functional as Ffrom torch import nn-from typing_extensions import TypedDictfrom kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_SHAPEfrom kornia.geometry.subpix import (diff --git a/tests/test_declared_imports.py b/tests/test_declared_imports.pyindex 1f3e549aa..721d76dbd 100644--- a/tests/test_declared_imports.py+++ b/tests/test_declared_imports.py@@ -77,8 +77,10 @@ DIST_TO_IMPORT = {}# Third-party modules that are allowed without appearing in ``pyproject.toml``: torch, which is a-# declared runtime dependency, installs them, so anything that can import torch has them too.-IMPLICIT_ALLOWED = {"typing_extensions"}+# declared runtime dependency, installs them, so anything that can import torch has them too. Empty+# since ``typing_extensions`` gave way to ``typing`` (every name kornia used is in the 3.11 stdlib);+# an entry here is a package kornia imports on torch's word alone, so keep it empty when you can.+IMPLICIT_ALLOWED: frozenset[str] = frozenset()# Extras that exist for contributors, not for users of the library: nothing a user runs may depend# on them, so they do not make a package "declared". Every other extra is user-facing and does.