π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Use --no-implicit-optional for type checking (#1910)
Shantanuacb01238be5b
diff --git a/kornia/augmentation/_2d/geometric/crop.py b/kornia/augmentation/_2d/geometric/crop.pyindex 239aba6ae..85393285d 100644--- a/kornia/augmentation/_2d/geometric/crop.py+++ b/kornia/augmentation/_2d/geometric/crop.py@@ -127,7 +127,7 @@ class RandomCrop(GeometricAugmentationBase2D):return paddingdef precrop_padding(- self, input: Tensor, padding: List[int] = None, flags: Optional[Dict[str, Any]] = None+ self, input: Tensor, padding: Optional[List[int]] = None, flags: Optional[Dict[str, Any]] = None) -> Tensor:flags = self.flags if flags is None else flagsif padding is None:diff --git a/kornia/augmentation/_3d/geometric/affine.py b/kornia/augmentation/_3d/geometric/affine.pyindex 7988895f0..df9b7f991 100644--- a/kornia/augmentation/_3d/geometric/affine.py+++ b/kornia/augmentation/_3d/geometric/affine.py@@ -98,6 +98,7 @@ class RandomAffine3D(AugmentationBase3D):Union[Tensor, Tuple[float, float], Tuple[Tuple[float, float], Tuple[float, float], Tuple[float, float]]]] = None,shears: Union[+ None,Tensor,float,Tuple[float, float],diff --git a/kornia/augmentation/random_generator/_3d/affine.py b/kornia/augmentation/random_generator/_3d/affine.pyindex 48be9c97a..3eb1f846c 100644--- a/kornia/augmentation/random_generator/_3d/affine.py+++ b/kornia/augmentation/random_generator/_3d/affine.py@@ -73,6 +73,7 @@ class AffineGenerator3D(RandomGeneratorBase):]] = None,shears: Union[+ None,torch.Tensor,float,Tuple[float, float],diff --git a/kornia/feature/adalam/adalam.py b/kornia/feature/adalam/adalam.pyindex ab999753d..1bcb9b3b2 100644--- a/kornia/feature/adalam/adalam.py+++ b/kornia/feature/adalam/adalam.py@@ -91,7 +91,7 @@ def match_adalam(class AdalamFilter:DEFAULT_CONFIG = get_adalam_default_config()- def __init__(self, custom_config: dict = None):+ def __init__(self, custom_config: Optional[dict] = None):"""This class acts as a wrapper to the method AdaLAM for outlier filtering.init args:@@ -116,13 +116,13 @@ class AdalamFilter:k2: torch.Tensor,putative_matches: torch.Tensor,scores: torch.Tensor,- mnn: torch.Tensor = None,- im1shape: tuple = None,- im2shape: tuple = None,- o1: torch.Tensor = None,- o2: torch.Tensor = None,- s1: torch.Tensor = None,- s2: torch.Tensor = None,+ mnn: Optional[torch.Tensor] = None,+ im1shape: Optional[tuple] = None,+ im2shape: Optional[tuple] = None,+ o1: Optional[torch.Tensor] = None,+ o2: Optional[torch.Tensor] = None,+ s1: Optional[torch.Tensor] = None,+ s2: Optional[torch.Tensor] = None,return_dist: bool = False,) -> Union[Tuple[Tensor, Tensor], Tensor]:"""Call the core functionality of AdaLAM, i.e. just outlier filtering. No sanity check is performed on thediff --git a/kornia/feature/sold2/backbones.py b/kornia/feature/sold2/backbones.pyindex f6fb50b2c..7be4ef6a3 100644--- a/kornia/feature/sold2/backbones.py+++ b/kornia/feature/sold2/backbones.py@@ -1,5 +1,5 @@"""Implements several backbone networks."""-from typing import Dict, List, Tuple, Union+from typing import Dict, List, Optional, Tuple, Unionimport torchimport torch.nn as nn@@ -63,7 +63,11 @@ class MultitaskHead(nn.Module):class Bottleneck2D(nn.Module):def __init__(- self, inplanes: int, planes: int, stride: Union[int, Tuple[int, int]] = 1, downsample: torch.nn.Module = None+ self,+ inplanes: int,+ planes: int,+ stride: Union[int, Tuple[int, int]] = 1,+ downsample: Optional[torch.nn.Module] = None,):super().__init__()diff --git a/kornia/feature/sold2/sold2_detector.py b/kornia/feature/sold2/sold2_detector.pyindex 325e691af..f3a0fe28c 100644--- a/kornia/feature/sold2/sold2_detector.py+++ b/kornia/feature/sold2/sold2_detector.py@@ -1,5 +1,5 @@import math-from typing import Dict, Tuple+from typing import Dict, Optional, Tupleimport torchimport torch.nn as nn@@ -62,7 +62,7 @@ class SOLD2_detector(nn.Module):>>> line_segments = sold2_detector(img)["line_segments"]"""- def __init__(self, pretrained: bool = True, config: Dict = None):+ def __init__(self, pretrained: bool = True, config: Optional[Dict] = None):super().__init__()# Initialize some parametersself.config = default_detector_cfg if config is None else configdiff --git a/kornia/utils/helpers.py b/kornia/utils/helpers.pyindex cf1bd7fdd..496833d90 100644--- a/kornia/utils/helpers.py+++ b/kornia/utils/helpers.py@@ -28,7 +28,7 @@ def get_cuda_device_if_available(index: int = 0) -> torch.device:return dev-def _deprecated(func: Callable = None, replace_with: Optional[str] = None):+def _deprecated(func: Optional[Callable] = None, replace_with: Optional[str] = None):if func is None:return partial(_deprecated, replace_with=replace_with)diff --git a/kornia/x/trainers.py b/kornia/x/trainers.pyindex 8d576e303..d1f75ea22 100644--- a/kornia/x/trainers.py+++ b/kornia/x/trainers.py@@ -70,7 +70,7 @@ class ObjectDetectionTrainer(Trainer):scheduler: torch.optim.lr_scheduler.CosineAnnealingLR,config: Configuration,num_classes: int,- callbacks: Dict[str, Callable] = None,+ callbacks: Optional[Dict[str, Callable]] = None,loss_computed_by_model: Optional[bool] = None,) -> None:if callbacks is None:diff --git a/setup.cfg b/setup.cfgindex 30404829b..c2b097396 100644--- a/setup.cfg+++ b/setup.cfg@@ -123,6 +123,7 @@ files = kornia, testpretty = Trueshow_error_codes = Trueignore_missing_imports = True+no_implicit_optional = True[pydocstyle]match = .*\.py