Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

style: enable ruff ISC (flake8-implicit-str-concat) rules (#4917)

Daisy DAI1f2285d9614c
diff --git a/.github/download-models-weights.py b/.github/download-models-weights.py
index 21bbe0bd3..ea7a1ef89 100644
--- a/.github/download-models-weights.py
+++ b/.github/download-models-weights.py
@@ -84,8 +84,10 @@ MODELS: dict[str, "str | list[str]"] = {
# HardNet: the default descriptor of LAFDescriptor, so nearly every composite.
"checkpoint_liberty_with_aug.pth": [
"https://huggingface.co/kornia/hardnet/resolve/main/checkpoint_liberty_with_aug.pth",
- "https://github.com/DagnyT/hardnet/raw/master/pretrained/train_liberty_with_aug/"
- "checkpoint_liberty_with_aug.pth",
+ (
+ "https://github.com/DagnyT/hardnet/raw/master/pretrained/train_liberty_with_aug/"
+ "checkpoint_liberty_with_aug.pth"
+ ),
],
# Patch descriptors with pretrained smoke/jit tests.
"HyNet_LIB.pth": [
diff --git a/benchmarks/color/flagship.py b/benchmarks/color/flagship.py
index a8aeedd3f..2f3ca3364 100644
--- a/benchmarks/color/flagship.py
+++ b/benchmarks/color/flagship.py
@@ -188,8 +188,10 @@ def main() -> None:
device,
units="img/s",
regimes=[
- "kornia/torchvision: batched float BCHW; opencv/PIL: uint8 HWC per-image loop (CPU), "
- "opencv Lab on float32; scikit-image: normalized float HWC per-image loop",
+ (
+ "kornia/torchvision: batched float BCHW; opencv/PIL: uint8 HWC per-image loop (CPU), "
+ "opencv Lab on float32; scikit-image: normalized float HWC per-image loop"
+ ),
"opencv (stacked): one cvtColor on the batch viewed as (B*H, W, 3); PIL: prebuilt Image objects",
],
missing=[(name, err) for lib, name, err in libs if lib is None],
diff --git a/benchmarks/contrib/flagship.py b/benchmarks/contrib/flagship.py
index 2ba4fc933..03d6a6c1c 100644
--- a/benchmarks/contrib/flagship.py
+++ b/benchmarks/contrib/flagship.py
@@ -149,8 +149,10 @@ def main() -> None:
device,
units="img/s",
regimes=[
- "kornia: batched float B1HW mask; opencv/scikit-image/SciPy: per-image loop (CPU), "
- "uint8 masks except bool for scikit-image and SciPy labeling"
+ (
+ "kornia: batched float B1HW mask; opencv/scikit-image/SciPy: per-image loop (CPU), "
+ "uint8 masks except bool for scikit-image and SciPy labeling"
+ )
],
missing=[(name, err) for lib, name, err in libs if lib is None],
)
diff --git a/benchmarks/enhance/flagship.py b/benchmarks/enhance/flagship.py
index 043419fbb..382b7f415 100644
--- a/benchmarks/enhance/flagship.py
+++ b/benchmarks/enhance/flagship.py
@@ -218,8 +218,10 @@ def main() -> None:
device,
units="img/s",
regimes=[
- "kornia/torchvision: batched float BCHW (torchvision equalize: uint8 BCHW); "
- "albumentations/opencv/PIL: uint8 HWC per-image loop (CPU); scikit-image: normalized float HWC loop",
+ (
+ "kornia/torchvision: batched float BCHW (torchvision equalize: uint8 BCHW); "
+ "albumentations/opencv/PIL: uint8 HWC per-image loop (CPU); scikit-image: normalized float HWC loop"
+ ),
"PIL: prebuilt Image objects; albumentations CLAHE equalizes only L in Lab, the others all 3 channels",
],
missing=[(label, imported[key][1]) for key, label in labels.items() if libs[key] is None],
diff --git a/benchmarks/feature/flagship.py b/benchmarks/feature/flagship.py
index 04e9c2fd5..e898d5ea8 100644
--- a/benchmarks/feature/flagship.py
+++ b/benchmarks/feature/flagship.py
@@ -194,8 +194,10 @@ def main() -> None:
device,
units="items/s",
regimes=[
- "kornia: batched float B1HW; opencv/scikit-image: grayscale per-image loop (CPU); "
- "items = images, except match_snn = descriptor-set pairs"
+ (
+ "kornia: batched float B1HW; opencv/scikit-image: grayscale per-image loop (CPU); "
+ "items = images, except match_snn = descriptor-set pairs"
+ )
],
missing=[(name, err) for lib, name, err in libs if lib is None],
)
diff --git a/benchmarks/filters/flagship.py b/benchmarks/filters/flagship.py
index 65af3e57f..c50d63b4e 100644
--- a/benchmarks/filters/flagship.py
+++ b/benchmarks/filters/flagship.py
@@ -437,9 +437,11 @@ def main() -> None:
device,
units="img/s",
regimes=[
- "kornia/torchvision: batched float BCHW; "
- "albumentations/opencv/kornia-rs/PIL: uint8 HWC per-image loop (CPU), except kornia-rs Sobel float32; "
- "scikit-image: normalized float HWC per-image loop except uint8 rank mean"
+ (
+ "kornia/torchvision: batched float BCHW; "
+ "albumentations/opencv/kornia-rs/PIL: uint8 HWC per-image loop (CPU), except kornia-rs Sobel float32; "
+ "scikit-image: normalized float HWC per-image loop except uint8 rank mean"
+ )
],
missing=missing,
)
diff --git a/benchmarks/morphology/flagship.py b/benchmarks/morphology/flagship.py
index c1bf20a22..df96ec162 100644
--- a/benchmarks/morphology/flagship.py
+++ b/benchmarks/morphology/flagship.py
@@ -194,9 +194,11 @@ def main() -> None:
device,
units="img/s",
regimes=[
- f"{KERNEL_SIZE}x{KERNEL_SIZE} square element; kornia: batched float BCHW; "
- "torchmorph: batched float32 BCHW (CUDA only); "
- "opencv/albumentations: uint8 HWC per-image loop (CPU); scikit-image: uint8 per-image, per-channel loop"
+ (
+ f"{KERNEL_SIZE}x{KERNEL_SIZE} square element; kornia: batched float BCHW; "
+ "torchmorph: batched float32 BCHW (CUDA only); "
+ "opencv/albumentations: uint8 HWC per-image loop (CPU); scikit-image: uint8 per-image, per-channel loop"
+ )
],
missing=[(name, err) for lib, name, err in libs if lib is None],
)
diff --git a/kornia/models/tiny_vit.py b/kornia/models/tiny_vit.py
index 4802356ea..54c05e5e8 100644
--- a/kornia/models/tiny_vit.py
+++ b/kornia/models/tiny_vit.py
@@ -689,13 +689,17 @@ urls: dict[str, dict[str, list[str]]] = {
],
"in1k_384": [
hf_url("tiny_vit", "tiny_vit_21m_22kto1k_384_distill.pth"),
- "https://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/"
- "tiny_vit_21m_22kto1k_384_distill.pth",
+ (
+ "https://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/"
+ "tiny_vit_21m_22kto1k_384_distill.pth"
+ ),
],
"in1k_512": [
hf_url("tiny_vit", "tiny_vit_21m_22kto1k_512_distill.pth"),
- "https://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/"
- "tiny_vit_21m_22kto1k_512_distill.pth",
+ (
+ "https://github.com/wkcn/TinyViT-model-zoo/releases/download/checkpoints/"
+ "tiny_vit_21m_22kto1k_512_distill.pth"
+ ),
],
},
}
diff --git a/pyproject.toml b/pyproject.toml
index 86318f2c8..7a8ada8f2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -245,7 +245,7 @@ select = [
# "FIX", # flake8-fixme
# "G", # flake8-logging-format
# "INP", # flake8-no-pep420
- # "ISC", # flake8-implicit-str-concat
+ "ISC", # flake8-implicit-str-concat
# "N", # pep8-naming
# "PD", # pandas-vet
# "PERF", # Perflint
diff --git a/tests/scripts/test_check_torch_env.py b/tests/scripts/test_check_torch_env.py
index a975312ef..2c8c26de3 100644
--- a/tests/scripts/test_check_torch_env.py
+++ b/tests/scripts/test_check_torch_env.py
@@ -193,8 +193,10 @@ def test_scan_installed_finds_no_duplicates_after_setuptools_adds_its_vendor_pat
[
sys.executable,
"-c",
- f"import sys; sys.path.insert(0, {str(script_dir)!r}); import setuptools; "
- "from check_torch_env import scan_installed; assert scan_installed()[1] == {}",
+ (
+ f"import sys; sys.path.insert(0, {str(script_dir)!r}); import setuptools; "
+ "from check_torch_env import scan_installed; assert scan_installed()[1] == {}"
+ ),
],
check=False,
capture_output=True,
diff --git a/tests/test_half_precision_ci.py b/tests/test_half_precision_ci.py
index d4ad03eb5..d29094ffc 100644
--- a/tests/test_half_precision_ci.py
+++ b/tests/test_half_precision_ci.py
@@ -267,8 +267,10 @@ def test_describe_audit_drift_reports_moves_stales_missings_and_count_drift() ->
)
assert _describe_audit_drift(audited, discovered) == [
- "audited entry tests/a.py:10 torch.rand has no call site; "
- "tests/a.py:11 torch.rand is not audited (the same call moved?)",
+ (
+ "audited entry tests/a.py:10 torch.rand has no call site; "
+ "tests/a.py:11 torch.rand is not audited (the same call moved?)"
+ ),
"audited entry tests/a.py:20 torch.randperm has no matching call site (stale entry)",
"audited entry tests/c.py:49 torch.randn is audited 2x but found 1x at that line",
"eager RNG call site tests/a.py:9 torch.randn is missing from the audit",
diff --git a/tests/test_known_failures.py b/tests/test_known_failures.py
index 63b163ba2..e556a051f 100644
--- a/tests/test_known_failures.py
+++ b/tests/test_known_failures.py
@@ -153,15 +153,19 @@ class TestKnownFailureOutcomes:
"@pytest.mark.xfail(reason='different xfail marker', strict=False)",
),
(
- "request.addfinalizer(lambda: pytest.skip('disabled in teardown')); "
- "raise RuntimeError('known failure')",
+ (
+ "request.addfinalizer(lambda: pytest.skip('disabled in teardown')); "
+ "raise RuntimeError('known failure')"
+ ),
"",
),
(
"raise RuntimeError('known failure')",
- "@pytest.fixture(autouse=True)\n"
- " def fail_setup():\n"
- " raise RuntimeError('setup failure')",
+ (
+ "@pytest.fixture(autouse=True)\n"
+ " def fail_setup():\n"
+ " raise RuntimeError('setup failure')"
+ ),
),
],
ids=[