From 11a6a1059e2108132b862e1a35dc79856f4be14f Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Fri, 19 Sep 2025 14:12:11 +0000 Subject: [PATCH 1/9] Change the minimum python version to 3.10 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bc127a6..a57eaa8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "dissect.hypervisor" description = "A Dissect module implementing parsers for various hypervisor disk, backup and configuration files" readme = "README.md" -requires-python = "~=3.9" +requires-python = ">=3.10" license.text = "Affero General Public License v3" authors = [ {name = "Dissect Team", email = "dissect@fox-it.com"} From 918eba4fe008ab48b2587d79ba2f312899407e96 Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Fri, 19 Sep 2025 14:48:15 +0000 Subject: [PATCH 2/9] Update deprecated license settings --- pyproject.toml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a57eaa8..9a6c81c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=65.5.0", "setuptools_scm[toml]>=6.4.0"] +requires = ["setuptools>=77.0.0", "setuptools_scm[toml]>=6.4.0"] build-backend = "setuptools.build_meta" [project] @@ -7,7 +7,8 @@ name = "dissect.hypervisor" description = "A Dissect module implementing parsers for various hypervisor disk, backup and configuration files" readme = "README.md" requires-python = ">=3.10" -license.text = "Affero General Public License v3" +license = "AGPL-3.0-or-later" +license-files = ["LICENSE", "COPYRIGHT"] authors = [ {name = "Dissect Team", email = "dissect@fox-it.com"} ] @@ -102,9 +103,6 @@ ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM1 known-first-party = ["dissect.hypervisor"] known-third-party = ["dissect"] -[tool.setuptools] -license-files = ["LICENSE", "COPYRIGHT"] - [tool.setuptools.packages.find] include = ["dissect.*"] From f011d79c09a7da772c7182fe061b17eeb69f812b Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Fri, 19 Sep 2025 15:39:21 +0000 Subject: [PATCH 3/9] remove 'License :: OSI approved' from specifiers --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9a6c81c..a74c232 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,6 @@ classifiers = [ "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Information Technology", - "License :: OSI Approved", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Internet :: Log Analysis", From c3467162f76551e4534419814d54a445ec0f2266 Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Mon, 22 Sep 2025 09:31:23 +0000 Subject: [PATCH 4/9] Change vermin minimum version to python3.10 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 83de25b..9b72638 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ deps = commands = ruff format --check dissect tests ruff check dissect tests - vermin -t=3.9- --no-tips --lint dissect tests + vermin -t=3.10- --no-tips --lint dissect tests [testenv:docs-build] allowlist_externals = make From b460fe5a2af345cf9d1e03ffc5d719a7d5b27d4b Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Tue, 23 Sep 2025 09:19:56 +0000 Subject: [PATCH 5/9] Update lint and fix steps tox.ini --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 9b72638..ed8db88 100644 --- a/tox.ini +++ b/tox.ini @@ -34,8 +34,8 @@ package = skip deps = ruff==0.11.10 commands = - ruff format dissect tests ruff check --fix dissect tests + ruff format dissect tests [testenv:lint] package = skip @@ -43,8 +43,8 @@ deps = ruff==0.11.10 vermin commands = - ruff format --check dissect tests ruff check dissect tests + ruff format --check dissect tests vermin -t=3.10- --no-tips --lint dissect tests [testenv:docs-build] From 1bdb03138c829ac4b8d1df0f364ea98980ce1737 Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Tue, 23 Sep 2025 09:31:57 +0000 Subject: [PATCH 6/9] Bump ruff version --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index ed8db88..827d58c 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ commands = [testenv:fix] package = skip deps = - ruff==0.11.10 + ruff==0.13.1 commands = ruff check --fix dissect tests ruff format dissect tests @@ -40,7 +40,7 @@ commands = [testenv:lint] package = skip deps = - ruff==0.11.10 + ruff==0.13.1 vermin commands = ruff check dissect tests From e1939222cf59dc1c3abb33094babf265c7295233 Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Mon, 22 Sep 2025 11:57:35 +0000 Subject: [PATCH 7/9] Fix linting for python3.10 --- dissect/hypervisor/disk/c_asif.pyi | 3 +-- dissect/hypervisor/disk/c_qcow2.pyi | 3 +-- dissect/hypervisor/disk/vhdx.py | 4 ++-- dissect/hypervisor/util/vmtar.py | 4 ++-- tests/disk/test_hdd.py | 2 +- tests/disk/test_qcow2.py | 10 +++++----- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/dissect/hypervisor/disk/c_asif.pyi b/dissect/hypervisor/disk/c_asif.pyi index be0e547..948cf1c 100644 --- a/dissect/hypervisor/disk/c_asif.pyi +++ b/dissect/hypervisor/disk/c_asif.pyi @@ -1,8 +1,7 @@ # Generated by cstruct-stubgen -from typing import BinaryIO, Literal, overload +from typing import BinaryIO, Literal, TypeAlias, overload import dissect.cstruct as __cs__ -from typing_extensions import TypeAlias class _c_asif(__cs__.cstruct): ASIF_HEADER_SIGNATURE: Literal[1936221303] = ... diff --git a/dissect/hypervisor/disk/c_qcow2.pyi b/dissect/hypervisor/disk/c_qcow2.pyi index 51db133..4fee1ef 100644 --- a/dissect/hypervisor/disk/c_qcow2.pyi +++ b/dissect/hypervisor/disk/c_qcow2.pyi @@ -1,8 +1,7 @@ # Generated by cstruct-stubgen -from typing import BinaryIO, Literal, overload +from typing import BinaryIO, Literal, TypeAlias, overload import dissect.cstruct as __cs__ -from typing_extensions import TypeAlias class _c_qcow2(__cs__.cstruct): MIN_CLUSTER_BITS: Literal[9] = ... diff --git a/dissect/hypervisor/disk/vhdx.py b/dissect/hypervisor/disk/vhdx.py index 592bb47..657afad 100644 --- a/dissect/hypervisor/disk/vhdx.py +++ b/dissect/hypervisor/disk/vhdx.py @@ -7,7 +7,7 @@ import os from functools import lru_cache from pathlib import Path -from typing import TYPE_CHECKING, Any, BinaryIO, Callable, Final +from typing import TYPE_CHECKING, Any, BinaryIO, Final from uuid import UUID from dissect.util.stream import AlignedStream @@ -29,7 +29,7 @@ from dissect.hypervisor.exceptions import InvalidSignature, InvalidVirtualDisk if TYPE_CHECKING: - from collections.abc import Iterator + from collections.abc import Callable, Iterator log = logging.getLogger(__name__) log.setLevel(os.getenv("DISSECT_LOG_VHDX", "CRITICAL")) diff --git a/dissect/hypervisor/util/vmtar.py b/dissect/hypervisor/util/vmtar.py index e52f8cc..329bdc9 100644 --- a/dissect/hypervisor/util/vmtar.py +++ b/dissect/hypervisor/util/vmtar.py @@ -62,12 +62,12 @@ def visoropen(cls, name: str, mode: str = "r", fileobj: BinaryIO | None = None, raise tarfile.TarError("visor currently only supports read mode") try: - from gzip import GzipFile + from gzip import GzipFile # noqa: PLC0415 except ImportError: raise tarfile.CompressionError("gzip module is not available") from None try: - from lzma import LZMAError, LZMAFile + from lzma import LZMAError, LZMAFile # noqa: PLC0415 except ImportError: raise tarfile.CompressionError("lzma module is not available") from None diff --git a/tests/disk/test_hdd.py b/tests/disk/test_hdd.py index cdfc5ad..1c08b74 100644 --- a/tests/disk/test_hdd.py +++ b/tests/disk/test_hdd.py @@ -61,7 +61,7 @@ def test_split_hdd(split_hdd: Path) -> None: start = 0 - for storage, split_size in zip(storages, split_sizes): + for storage, split_size in zip(storages, split_sizes, strict=False): assert storage.start == start assert storage.end == start + split_size assert len(storage.images) == 1 diff --git a/tests/disk/test_qcow2.py b/tests/disk/test_qcow2.py index 9821600..e7d6e42 100644 --- a/tests/disk/test_qcow2.py +++ b/tests/disk/test_qcow2.py @@ -31,7 +31,7 @@ def test_basic(basic_qcow2: BinaryIO) -> None: def test_data_file(data_file_qcow2: Path) -> None: # Test with file handle with gzip.open(data_file_qcow2, "rb") as fh: - with pytest.raises(Error, match="data-file required but not provided \\(image_data_file = 'data-file.bin'\\)"): + with pytest.raises(Error, match=r"data-file required but not provided \(image_data_file = 'data-file.bin'\)"): QCow2(fh) with gzip.open(data_file_qcow2.with_name("data-file.bin.gz"), "rb") as fh_bin: @@ -47,7 +47,7 @@ def test_data_file(data_file_qcow2: Path) -> None: # Test with allow_no_data_file qcow2 = QCow2(fh, allow_no_data_file=True) assert qcow2.data_file is None - with pytest.raises(Error, match="data-file required but not provided \\(image_data_file = 'data-file.bin'\\)"): + with pytest.raises(Error, match=r"data-file required but not provided \(image_data_file = 'data-file.bin'\)"): qcow2.open() # Test with Path @@ -68,12 +68,12 @@ def test_backing_file(backing_chain_qcow2: tuple[Path, Path, Path]) -> None: # Test with file handle with gzip.open(file1, "rb") as fh1, gzip.open(file2, "rb") as fh2, gzip.open(file3, "rb") as fh3: with pytest.raises( - Error, match="backing-file required but not provided \\(auto_backing_file = 'backing-chain-2.qcow2'\\)" + Error, match=r"backing-file required but not provided \(auto_backing_file = 'backing-chain-2.qcow2'\)" ): QCow2(fh1) with pytest.raises( - Error, match="backing-file required but not provided \\(auto_backing_file = 'backing-chain-3.qcow2'\\)" + Error, match=r"backing-file required but not provided \(auto_backing_file = 'backing-chain-3.qcow2'\)" ): QCow2(fh1, backing_file=fh2) @@ -87,7 +87,7 @@ def test_backing_file(backing_chain_qcow2: tuple[Path, Path, Path]) -> None: qcow2 = QCow2(fh1, allow_no_backing_file=True) assert qcow2.backing_file is None with pytest.raises( - Error, match="backing-file required but not provided \\(auto_backing_file = 'backing-chain-2.qcow2'\\)" + Error, match=r"backing-file required but not provided \(auto_backing_file = 'backing-chain-2.qcow2'\)" ): qcow2.open() From 072dbae6001f39c5ad932868c09e48a0dc37d31f Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Tue, 23 Sep 2025 13:43:45 +0000 Subject: [PATCH 8/9] Update project to use dependency groups --- pyproject.toml | 20 ++++++++++++++++++++ tox.ini | 14 +++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a74c232..2f3341d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,26 @@ dev = [ "dissect.util>=3.0.dev,<4.0.dev", ] +[dependency-groups] +test = [ + "pytest", +] +lint = [ + "ruff==0.13.1", + "vermin", +] +build = [ + "build", +] +debug = [ + "ipdb", +] +dev = [ + {include-group = "test"}, + {include-group = "lint"}, + {include-group = "debug"}, +] + [project.scripts] envelope-decrypt = "dissect.hypervisor.tools.envelope:main" vmtar = "dissect.hypervisor.tools.vmtar:main" diff --git a/tox.ini b/tox.ini index 827d58c..284a4ba 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ envlist = lint, py3, pypy3 # requires if they are not available on the host system. This requires the # locally installed tox to have a minimum version 3.3.0. This means the names # of the configuration options are still according to the tox 3.x syntax. -minversion = 4.4.3 +minversion = 4.27.0 # This version of virtualenv will install setuptools version 68.2.2 and pip # 23.3.1. These versions fully support python projects defined only through a # pyproject.toml file (PEP-517/PEP-518/PEP-621). This pip version also support @@ -14,9 +14,9 @@ requires = virtualenv>=20.24.6 [testenv] extras = dev deps = - pytest pytest-cov coverage +dependency_groups = test commands = pytest --basetemp="{envtmpdir}" {posargs:--color=yes --cov=dissect --cov-report=term-missing -v tests} coverage report @@ -24,24 +24,20 @@ commands = [testenv:build] package = skip -deps = - build +dependency_groups = build commands = pyproject-build [testenv:fix] package = skip -deps = - ruff==0.13.1 +dependency_groups = lint commands = ruff check --fix dissect tests ruff format dissect tests [testenv:lint] package = skip -deps = - ruff==0.13.1 - vermin +dependency_groups = lint commands = ruff check dissect tests ruff format --check dissect tests From 2bb2c02c9f484f9d0a8487baf09d3ba75d983a24 Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Wed, 24 Sep 2025 12:38:14 +0000 Subject: [PATCH 9/9] Changing required ruff version to ">=0.13.1" --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2f3341d..8404869 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ vmtar = "dissect.hypervisor.tools.vmtar:main" [tool.ruff] line-length = 120 -required-version = ">=0.11.0" +required-version = ">=0.13.1" [tool.ruff.format] docstring-code-format = true