diff --git a/dissect/executable/elf/elf.py b/dissect/executable/elf/elf.py index 8bae0c3..6ca5cbf 100644 --- a/dissect/executable/elf/elf.py +++ b/dissect/executable/elf/elf.py @@ -3,7 +3,7 @@ import io from functools import cached_property, lru_cache from operator import itemgetter -from typing import TYPE_CHECKING, BinaryIO, Callable, Generic, TypeVar +from typing import TYPE_CHECKING, BinaryIO, Generic, TypeVar from dissect.executable.elf.c_elf import ( SHN, @@ -19,7 +19,7 @@ from dissect.executable.exception import InvalidSignatureError if TYPE_CHECKING: - from collections.abc import Iterator + from collections.abc import Callable, Iterator from dissect.cstruct import cstruct diff --git a/dissect/executable/pe/c_pe.pyi b/dissect/executable/pe/c_pe.pyi index 1efb7de..bfdf379 100644 --- a/dissect/executable/pe/c_pe.pyi +++ b/dissect/executable/pe/c_pe.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_pe(__cs__.cstruct): IMAGE_DOS_SIGNATURE: Literal[23117] = ... diff --git a/dissect/executable/pe/directory/delay_import.py b/dissect/executable/pe/directory/delay_import.py index 138e5af..bf43c7d 100644 --- a/dissect/executable/pe/directory/delay_import.py +++ b/dissect/executable/pe/directory/delay_import.py @@ -126,7 +126,7 @@ def functions(self) -> list[DelayImportFunction]: return [ DelayImportFunction(self, name_thunk, address_thunk, bound_thunk, unload_thunk) for name_thunk, address_thunk, bound_thunk, unload_thunk in zip( - name_table, address_table, bound_table, unload_table + name_table, address_table, bound_table, unload_table, strict=False ) ] diff --git a/dissect/executable/pe/directory/export.py b/dissect/executable/pe/directory/export.py index 3bd4762..5431ee6 100644 --- a/dissect/executable/pe/directory/export.py +++ b/dissect/executable/pe/directory/export.py @@ -79,7 +79,7 @@ def functions(self) -> list[ExportFunction]: self.pe.vfh.seek(self.header.AddressOfNameOrdinals) ordinals = c_pe.USHORT[self.header.NumberOfNames](self.pe.vfh) - for name_ptr, ordinal in zip(names, ordinals): + for name_ptr, ordinal in zip(names, ordinals, strict=False): self.pe.vfh.seek(name_ptr) name = c_pe.CHAR[None](self.pe.vfh).decode() diff --git a/dissect/executable/pe/directory/imports.py b/dissect/executable/pe/directory/imports.py index cde895d..27ebfe2 100644 --- a/dissect/executable/pe/directory/imports.py +++ b/dissect/executable/pe/directory/imports.py @@ -108,7 +108,7 @@ def functions(self) -> list[ImportFunction]: return [ ImportFunction(self, lookup_thunk, address_thunk) - for lookup_thunk, address_thunk in zip(lookup_table, address_table) + for lookup_thunk, address_thunk in zip(lookup_table, address_table, strict=False) ] @cached_property diff --git a/dissect/executable/pe/directory/resource.py b/dissect/executable/pe/directory/resource.py index 61d4fef..382f876 100644 --- a/dissect/executable/pe/directory/resource.py +++ b/dissect/executable/pe/directory/resource.py @@ -2,18 +2,10 @@ from functools import cached_property from io import BytesIO -from typing import TYPE_CHECKING, Any, BinaryIO, Union - -from dissect.util.ts import from_unix, wintimestamp - -try: - from typing import TypeAlias # novermin -except ImportError: - # COMPAT: Remove this when we drop Python 3.9 - TypeAlias = Any - +from typing import TYPE_CHECKING, Any, BinaryIO, TypeAlias from dissect.util.stream import RangeStream +from dissect.util.ts import from_unix, wintimestamp from dissect.executable.pe.c_pe import c_pe from dissect.executable.pe.directory.base import DataDirectory @@ -268,7 +260,7 @@ def vs_version_info(self, language: str | int | None = None) -> dict | None: if len(version) != 1: raise ValueError(f"Expected exactly one version resource, found {len(version)}") - _Node: TypeAlias = tuple[str, Union[str, bytes, None], list["_Node"]] + _Node: TypeAlias = tuple[str, str | bytes | None, list["_Node"]] def _parse_lvt(fh: BinaryIO) -> _Node | None: start = fh.tell() diff --git a/pyproject.toml b/pyproject.toml index a84072e..be1ad15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [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] name = "dissect.executable" description = "A Dissect module implementing a parsers for various executable formats such as PE, ELF and Macho-O" readme = "README.md" -requires-python = "~=3.9" +requires-python = ">=3.10" license = "AGPL-3.0-or-later" license-files = ["LICENSE", "COPYRIGHT"] authors = [ @@ -41,9 +41,29 @@ 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"}, +] + [tool.ruff] line-length = 120 -required-version = ">=0.12.0" +required-version = ">=0.13.1" [tool.ruff.format] docstring-code-format = true diff --git a/tox.ini b/tox.ini index 965587c..9685232 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,26 +24,24 @@ commands = [testenv:build] package = skip -deps = - build +dependency_groups = build commands = pyproject-build [testenv:fix] package = skip -deps = - ruff==0.12.3 +dependency_groups = lint commands = + ruff check --fix dissect tests ruff format dissect tests [testenv:lint] package = skip -deps = - ruff==0.12.3 - vermin +dependency_groups = lint commands = ruff check dissect tests - vermin -t=3.9- --no-tips --lint dissect tests + ruff format --check dissect tests + vermin -t=3.10- --no-tips --lint dissect tests [flake8] max-line-length = 120