π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix mypy complaints (#3042)
Dmytro Mishkinbea928eb2ac8
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 3db2a6d0e..c49419ae0 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -15,12 +15,12 @@ repos:exclude: ^$|.devcontainer- repo: https://github.com/tox-dev/pyproject-fmt- rev: "2.2.4"+ rev: "2.4.3"hooks:- id: pyproject-fmt- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.6.9+ rev: v0.7.0hooks:- id: ruffargs: [--fix, --exit-non-zero-on-fix]diff --git a/kornia/contrib/extract_patches.py b/kornia/contrib/extract_patches.pyindex ee093eea2..21565f52d 100644--- a/kornia/contrib/extract_patches.py+++ b/kornia/contrib/extract_patches.py@@ -371,7 +371,7 @@ def combine_tensor_patches()if unpadding:- ones = pad(ones, pad=unpadding) # type: ignore+ ones = pad(ones, pad=unpadding)restored_size = ones.shape[2:]patches = patches.permute(0, 2, 3, 4, 1)@@ -387,12 +387,12 @@ def combine_tensor_patches(unfold_ones = F.unfold(ones, kernel_size=window_size, stride=stride)norm_map = F.fold(input=unfold_ones, output_size=restored_size, kernel_size=window_size, stride=stride)if unpadding:- norm_map = pad(norm_map, [-i for i in unpadding]) # type: ignore+ norm_map = pad(norm_map, [-i for i in unpadding])# Restored tensorsaturated_restored_tensor = F.fold(input=patches, output_size=restored_size, kernel_size=window_size, stride=stride)if unpadding:- saturated_restored_tensor = pad(saturated_restored_tensor, [-i for i in unpadding]) # type: ignore+ saturated_restored_tensor = pad(saturated_restored_tensor, [-i for i in unpadding])# Remove satuation effect due to multiple summationsrestored_tensor = saturated_restored_tensor / (norm_map + eps)diff --git a/kornia/models/detector/rtdetr.py b/kornia/models/detector/rtdetr.pyindex 4bc1c6bd2..f6ed6a3a4 100644--- a/kornia/models/detector/rtdetr.py+++ b/kornia/models/detector/rtdetr.py@@ -76,7 +76,7 @@ class RTDETRDetectorBuilder:DETRPostProcessor(confidence_threshold,num_classes=config.num_classes if config is not None else 80,- confidence_filtering=confidence_filtering or not torch.onnx.is_in_onnx_export,+ confidence_filtering=confidence_filtering or not torch.onnx.is_in_onnx_export(),),)diff --git a/kornia/utils/helpers.py b/kornia/utils/helpers.pyindex 4805afdae..050326db5 100644--- a/kornia/utils/helpers.py+++ b/kornia/utils/helpers.py@@ -349,7 +349,7 @@ def dict_to_dataclass(dict_obj: Dict[str, Any], dataclass_type: Type[T]) -> T:constructor_args = {}for key, value in dict_obj.items():if key in field_types and is_dataclass(field_types[key]):- constructor_args[key] = dict_to_dataclass(value, field_types[key])+ constructor_args[key] = dict_to_dataclass(value, field_types[key]) # type: ignoreelse:constructor_args[key] = value# TODO: remove type ignore when https://github.com/python/mypy/issues/14941 be andressed