Skip to content

Commit 87bbf95

Browse files
committed
chore(ci): enable Python 3.13 support
Signed-off-by: Rickypanta0 <rickypanta.dev@gmail.com>
1 parent f006ab7 commit 87bbf95

File tree

44 files changed

+128
-10472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+128
-10472
lines changed

.github/workflows/pre_merge.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set up Python
3131
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6
3232
with:
33-
python-version: "3.10"
33+
python-version: "3.13"
3434
- name: Install Tox
3535
run: pip install tox
3636
- name: Code quality checks
@@ -45,6 +45,8 @@ jobs:
4545
include:
4646
- python-version: "3.10"
4747
tox-env: "py310"
48+
- python-version: "3.13"
49+
tox-env: "py313"
4850
steps:
4951
- name: Checkout repository
5052
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

docs/source/markdown/guides/developer/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Set up your development environment to start contributing. This involves install
1818
1. Create and activate a new Conda environment:
1919

2020
```bash
21-
conda create -n anomalib_dev python=3.10
21+
conda create -n anomalib_dev python=3.13
2222
conda activate anomalib_dev
2323
```
2424

pyproject.toml

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ classifiers = [
1818
"Intended Audience :: Developers",
1919
"License :: OSI Approved :: Apache Software License",
2020
"Programming Language :: Python",
21-
"Programming Language :: Python :: 3",
2221
"Programming Language :: Python :: 3.10",
2322
"Programming Language :: Python :: 3.11",
2423
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
2525
"Topic :: Software Development :: Libraries",
2626
"Topic :: Scientific/Engineering :: Artificial Intelligence",
2727
]
@@ -100,19 +100,19 @@ test = [
100100
]
101101
# PyTorch dependency groups
102102
cpu = [
103-
"torch>=2.4.0,<=2.8.0",
103+
"torch>=2.4.0",
104104
"torchvision>=0.19.0",
105105
]
106106
cu118 = [
107-
"torch>=2.4.0,<=2.8.0",
108-
"torchvision>=0.19.0",
107+
"torch>=2.4.0,<=2.5.1 ; python_version < '3.13'",
108+
"torchvision>=0.19.0 ; python_version < '3.13'",
109109
]
110110
cu121 = [
111-
"torch>=2.4.0,<=2.8.0",
112-
"torchvision>=0.19.0",
111+
"torch>=2.4.0 ; python_version < '3.13'",
112+
"torchvision>=0.19.0 ; python_version < '3.13'",
113113
]
114114
cu124 = [
115-
"torch>=2.4.0,<=2.8.0",
115+
"torch>=2.4.0",
116116
"torchvision>=0.19.0",
117117
]
118118
cu130 = [
@@ -238,6 +238,44 @@ pytorch-triton-xpu = [
238238
# Enable preview features
239239
preview = true
240240

241+
# Exclude a variety of commonly ignored directories.
242+
exclude = [
243+
".bzr",
244+
".direnv",
245+
".eggs",
246+
".git",
247+
".hg",
248+
".mypy_cache",
249+
".nox",
250+
".pants.d",
251+
".pytype",
252+
".ruff_cache",
253+
".svn",
254+
".tox",
255+
".venv",
256+
"__pypackages__",
257+
"_build",
258+
"buck-out",
259+
"build",
260+
"dist",
261+
"node_modules",
262+
"venv",
263+
]
264+
265+
# Same as Black.
266+
line-length = 120
267+
268+
# Assume Python 3.10.
269+
target-version = "py310"
270+
271+
# Allow imports relative to the "src" and "tests" directories.
272+
src = ["src", "tests"]
273+
274+
[tool.ruff.lint]
275+
276+
# Allow unused variables when underscore-prefixed.
277+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
278+
241279
# Enable rules
242280
select = [
243281
"F", # Pyflakes (`F`)
@@ -292,6 +330,7 @@ select = [
292330

293331
ignore = [
294332
# pydocstyle
333+
"COM812",
295334
"D107", # Missing docstring in __init__
296335

297336
# pylint
@@ -346,57 +385,21 @@ ignore = [
346385
fixable = ["ALL"]
347386
unfixable = []
348387

349-
# Exclude a variety of commonly ignored directories.
350-
exclude = [
351-
".bzr",
352-
".direnv",
353-
".eggs",
354-
".git",
355-
".hg",
356-
".mypy_cache",
357-
".nox",
358-
".pants.d",
359-
".pytype",
360-
".ruff_cache",
361-
".svn",
362-
".tox",
363-
".venv",
364-
"__pypackages__",
365-
"_build",
366-
"buck-out",
367-
"build",
368-
"dist",
369-
"node_modules",
370-
"venv",
371-
]
372-
373-
# Same as Black.
374-
line-length = 120
375-
376-
# Allow unused variables when underscore-prefixed.
377-
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
378-
379-
# Assume Python 3.10.
380-
target-version = "py310"
381-
382-
# Allow imports relative to the "src" and "tests" directories.
383-
src = ["src", "tests"]
384-
385-
[tool.ruff.mccabe]
388+
[tool.ruff.lint.mccabe]
386389
# Unlike Flake8, default to a complexity level of 10.
387390
max-complexity = 15
388391

389392

390-
[tool.ruff.pydocstyle]
393+
[tool.ruff.lint.pydocstyle]
391394
convention = "google"
392395

393-
[tool.ruff.flake8-copyright]
396+
[tool.ruff.lint.flake8-copyright]
394397
notice-rgx = """
395398
# Copyright \\(C\\) (\\d{4}(-\\d{4})?) Intel Corporation
396399
# SPDX-License-Identifier: Apache-2\\.0
397400
"""
398401

399-
[tool.ruff.per-file-ignores]
402+
[tool.ruff.lint.per-file-ignores]
400403
"examples/notebooks/**/*" = ["CPY001"]
401404

402405
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

src/anomalib/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
with a focus on reproducibility and ease of use.
3333
"""
3434

35-
from enum import Enum
35+
from enum import StrEnum
3636

3737
__version__ = "2.3.0dev"
3838

3939

40-
class LearningType(str, Enum):
40+
class LearningType(StrEnum):
4141
"""Learning type defining how the model learns from the dataset samples.
4242
4343
This enum defines the different learning paradigms supported by anomalib models:
@@ -62,7 +62,7 @@ class LearningType(str, Enum):
6262
FEW_SHOT = "few_shot"
6363

6464

65-
class TaskType(str, Enum):
65+
class TaskType(StrEnum):
6666
"""Task type defining the model's prediction output format.
6767
6868
This enum defines the different task types supported by anomalib models:
@@ -88,7 +88,7 @@ class TaskType(str, Enum):
8888
SEGMENTATION = "segmentation"
8989

9090

91-
class PrecisionType(str, Enum):
91+
class PrecisionType(StrEnum):
9292
"""Precision type defining the numerical precision used in model computations.
9393
9494
This enum defines the different precision types supported by anomalib models:

src/anomalib/data/dataclasses/numpy/depth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
(224, 224)
2727
"""
2828

29+
from collections.abc import Callable
2930
from dataclasses import dataclass
31+
from typing import ClassVar
3032

3133
import numpy as np
3234

@@ -65,6 +67,7 @@ class NumpyDepthItem(
6567
"""
6668

6769

70+
@dataclass
6871
class NumpyDepthBatch(
6972
BatchIterateMixin[NumpyDepthItem],
7073
NumpyDepthBatchValidator,
@@ -87,4 +90,4 @@ class NumpyDepthBatch(
8790
tensor-like fields.
8891
"""
8992

90-
item_class = NumpyDepthItem
93+
item_class: ClassVar[Callable] = NumpyDepthItem

src/anomalib/data/dataclasses/torch/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
from anomalib.data.dataclasses.generic import ImageT, _GenericBatch, _GenericItem
2222

23-
NumpyT = TypeVar("NumpyT")
24-
2523

2624
class InferenceBatch(NamedTuple):
2725
"""Batch for use in torch and inference models.
@@ -43,6 +41,9 @@ class InferenceBatch(NamedTuple):
4341
pred_mask: torch.Tensor | None = None
4442

4543

44+
NumpyT = TypeVar("NumpyT")
45+
46+
4647
@dataclass
4748
class ToNumpyMixin(Generic[NumpyT]):
4849
"""Mixin for converting torch-based dataclasses to numpy.

src/anomalib/data/datamodules/depth/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
"""Anomalib Depth Data Modules."""
55

6-
from enum import Enum
6+
from enum import StrEnum
77

88
from .adam_3d import ADAM3D
99
from .folder_3d import Folder3D
1010
from .mvtec_3d import MVTec3D
1111

1212

13-
class DepthDataFormat(str, Enum):
13+
class DepthDataFormat(StrEnum):
1414
"""Supported Depth Dataset Types."""
1515

1616
MVTEC_3D = "mvtec_3d"

src/anomalib/data/datamodules/image/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
... )
3030
"""
3131

32-
from enum import Enum
32+
from enum import StrEnum
3333

3434
from .bmad import BMAD
3535
from .btech import BTech
@@ -46,7 +46,7 @@
4646
from .visa import Visa
4747

4848

49-
class ImageDataFormat(str, Enum):
49+
class ImageDataFormat(StrEnum):
5050
"""Supported Image Dataset Types.
5151
5252
The following dataset formats are supported:

src/anomalib/data/datamodules/video/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
... )
2222
"""
2323

24-
from enum import Enum
24+
from enum import StrEnum
2525

2626
from .avenue import Avenue
2727
from .shanghaitech import ShanghaiTech
2828
from .ucsd_ped import UCSDped
2929

3030

31-
class VideoDataFormat(str, Enum):
31+
class VideoDataFormat(StrEnum):
3232
"""Supported Video Dataset Types.
3333
3434
The following dataset formats are supported:

src/anomalib/data/datasets/base/video.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from abc import ABC
2424
from collections.abc import Callable
25-
from enum import Enum
25+
from enum import StrEnum
2626

2727
import torch
2828
from pandas import DataFrame
@@ -36,7 +36,7 @@
3636
from .image import AnomalibDataset
3737

3838

39-
class VideoTargetFrame(str, Enum):
39+
class VideoTargetFrame(StrEnum):
4040
"""Target frame for a video-clip.
4141
4242
Used in multi-frame models to determine which frame's ground truth information

0 commit comments

Comments
 (0)