π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Add bandit B101 test and fix (#1248)
Edgar Riba4558fecf2e5f
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 790683d67..4c22e042e 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -51,11 +51,11 @@ repos:rev: 1.7.0hooks:- id: bandit+ language_version: python3+ exclude: ^test/args:- - --recursive- - --skip- - "B101,B311,B404,B602,B603,B607"- - .+ - -s+ - "B311,B404,B602,B603,B607"- repo: https://github.com/myint/docformatterrev: v1.4diff --git a/kornia/augmentation/container/patch.py b/kornia/augmentation/container/patch.pyindex 8adf90580..084411332 100644--- a/kornia/augmentation/container/patch.py+++ b/kornia/augmentation/container/patch.py@@ -109,11 +109,12 @@ class PatchSequential(ImageSequential):# will only apply [1, 4] augmentations per patch_random_apply = (1, 4)elif patchwise_apply and random_apply is False:- assert len(args) == grid_size[0] * grid_size[1], (- "The number of processing modules must be equal with grid size."- f"Got {len(args)} and {grid_size[0] * grid_size[1]}. "- "Please set random_apply = True or patchwise_apply = False."- )+ if len(args) != grid_size[0] * grid_size[1]:+ raise ValueError(+ "The number of processing modules must be equal with grid size."+ f"Got {len(args)} and {grid_size[0] * grid_size[1]}. "+ "Please set random_apply = True or patchwise_apply = False."+ )_random_apply = random_applyelif patchwise_apply and isinstance(random_apply, (int, tuple)):raise ValueError(f"Only boolean value allowed when `patchwise_apply` is set to True. Got {random_apply}.")@@ -122,7 +123,8 @@ class PatchSequential(ImageSequential):super().__init__(*args, same_on_batch=same_on_batch, return_transform=False, keepdim=keepdim, random_apply=_random_apply)- assert padding in ["same", "valid"], f"`padding` must be either `same` or `valid`. Got {padding}."+ if padding not in ("same", "valid"):+ raise ValueError(f"`padding` must be either `same` or `valid`. Got {padding}.")self.grid_size = grid_sizeself.padding = paddingself.patchwise_apply = patchwise_apply