dissect.cstruct 4.6.dev8__tar.gz → 4.7.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/PKG-INFO +3 -4
  2. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/cstruct.py +1 -2
  3. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/expression.py +3 -1
  4. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/tools/stubgen.py +1 -2
  5. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/base.py +3 -5
  6. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/structure.py +3 -3
  7. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/PKG-INFO +3 -4
  8. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/pyproject.toml +26 -8
  9. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_basic.py +1 -1
  10. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_parser.py +1 -1
  11. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_tools_stubgen.py +1 -2
  12. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tox.ini +8 -12
  13. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/.git-blame-ignore-revs +0 -0
  14. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/.gitattributes +0 -0
  15. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/CHANGELOG.md +0 -0
  16. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/COPYRIGHT +0 -0
  17. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/LICENSE +0 -0
  18. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/MANIFEST.in +0 -0
  19. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/README.md +0 -0
  20. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/__init__.py +0 -0
  21. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/bitbuffer.py +0 -0
  22. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/compiler.py +0 -0
  23. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/exceptions.py +0 -0
  24. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/parser.py +0 -0
  25. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/tools/__init__.py +0 -0
  26. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/__init__.py +0 -0
  27. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/char.py +0 -0
  28. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/enum.py +0 -0
  29. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/flag.py +0 -0
  30. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/int.py +0 -0
  31. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/leb128.py +0 -0
  32. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/packed.py +0 -0
  33. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/pointer.py +0 -0
  34. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/void.py +0 -0
  35. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/wchar.py +0 -0
  36. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect/cstruct/utils.py +0 -0
  37. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
  38. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
  39. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/entry_points.txt +0 -0
  40. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/requires.txt +0 -0
  41. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/top_level.txt +0 -0
  42. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/examples/disk.py +0 -0
  43. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/examples/mirai.py +0 -0
  44. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/examples/pe.py +0 -0
  45. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/examples/protobuf.py +0 -0
  46. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/examples/secdesc.py +0 -0
  47. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/setup.cfg +0 -0
  48. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/__init__.py +0 -0
  49. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/_data/testdef.txt +0 -0
  50. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/_docs/Makefile +0 -0
  51. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/_docs/__init__.py +0 -0
  52. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/_docs/conf.py +0 -0
  53. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/_docs/index.rst +0 -0
  54. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/conftest.py +0 -0
  55. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_align.py +0 -0
  56. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_annotations.py +0 -0
  57. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_bitbuffer.py +0 -0
  58. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_bitfield.py +0 -0
  59. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_compiler.py +0 -0
  60. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_ctypes.py +0 -0
  61. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_expression.py +0 -0
  62. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_base.py +0 -0
  63. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_char.py +0 -0
  64. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_custom.py +0 -0
  65. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_enum.py +0 -0
  66. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_flag.py +0 -0
  67. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_int.py +0 -0
  68. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_leb128.py +0 -0
  69. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_packed.py +0 -0
  70. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_pointer.py +0 -0
  71. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_structure.py +0 -0
  72. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_union.py +0 -0
  73. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_void.py +0 -0
  74. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_types_wchar.py +0 -0
  75. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/test_utils.py +0 -0
  76. {dissect_cstruct-4.6.dev8 → dissect_cstruct-4.7.dev1}/tests/utils.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.cstruct
3
- Version: 4.6.dev8
3
+ Version: 4.7.dev1
4
4
  Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
- License: Apache License 2.0
6
+ License-Expression: Apache-2.0
7
7
  Project-URL: homepage, https://dissect.tools
8
8
  Project-URL: documentation, https://docs.dissect.tools/en/latest/projects/dissect.cstruct
9
9
  Project-URL: repository, https://github.com/fox-it/dissect.cstruct
@@ -12,14 +12,13 @@ Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Environment :: Console
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Intended Audience :: Information Technology
15
- Classifier: License :: OSI Approved
16
15
  Classifier: Operating System :: OS Independent
17
16
  Classifier: Programming Language :: Python :: 3
18
17
  Classifier: Topic :: Internet :: Log Analysis
19
18
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
19
  Classifier: Topic :: Security
21
20
  Classifier: Topic :: Utilities
22
- Requires-Python: ~=3.9
21
+ Requires-Python: >=3.10
23
22
  Description-Content-Type: text/markdown
24
23
  License-File: LICENSE
25
24
  License-File: COPYRIGHT
@@ -30,8 +30,7 @@ from dissect.cstruct.types import (
30
30
 
31
31
  if TYPE_CHECKING:
32
32
  from collections.abc import Iterable
33
-
34
- from typing_extensions import TypeAlias
33
+ from typing import TypeAlias
35
34
 
36
35
 
37
36
  T = TypeVar("T", bound=BaseType)
@@ -1,11 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import string
4
- from typing import TYPE_CHECKING, Callable, ClassVar
4
+ from typing import TYPE_CHECKING, ClassVar
5
5
 
6
6
  from dissect.cstruct.exceptions import ExpressionParserError, ExpressionTokenizerError
7
7
 
8
8
  if TYPE_CHECKING:
9
+ from collections.abc import Callable
10
+
9
11
  from dissect.cstruct import cstruct
10
12
 
11
13
 
@@ -39,10 +39,9 @@ def generate_file_stub(path: Path, base: Path) -> str:
39
39
 
40
40
  header = [
41
41
  "# Generated by cstruct-stubgen",
42
- "from typing import BinaryIO, Literal, overload",
42
+ "from typing import BinaryIO, Literal, TypeAlias, overload",
43
43
  "",
44
44
  "import dissect.cstruct as __cs__",
45
- "from typing_extensions import TypeAlias",
46
45
  ]
47
46
  body = []
48
47
 
@@ -2,12 +2,14 @@ from __future__ import annotations
2
2
 
3
3
  import functools
4
4
  from io import BytesIO
5
- from typing import TYPE_CHECKING, Any, BinaryIO, Callable, ClassVar, TypeVar
5
+ from typing import TYPE_CHECKING, Any, BinaryIO, ClassVar, TypeVar
6
6
 
7
7
  from dissect.cstruct.exceptions import ArraySizeError
8
8
  from dissect.cstruct.expression import Expression
9
9
 
10
10
  if TYPE_CHECKING:
11
+ from collections.abc import Callable
12
+
11
13
  from typing_extensions import Self
12
14
 
13
15
  from dissect.cstruct.cstruct import cstruct
@@ -60,10 +62,6 @@ class MetaType(type):
60
62
 
61
63
  def __len__(cls) -> int:
62
64
  """Return the byte size of the type."""
63
- # Python 3.9 compat thing for bound type vars
64
- if cls is BaseType:
65
- return 0
66
-
67
65
  if cls.size is None:
68
66
  raise TypeError("Dynamic size")
69
67
 
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import io
4
4
  from collections import ChainMap
5
- from collections.abc import MutableMapping
5
+ from collections.abc import Callable, MutableMapping
6
6
  from contextlib import contextmanager
7
7
  from enum import Enum
8
8
  from functools import lru_cache
@@ -10,7 +10,7 @@ from itertools import chain
10
10
  from operator import attrgetter
11
11
  from textwrap import dedent
12
12
  from types import FunctionType
13
- from typing import TYPE_CHECKING, Any, BinaryIO, Callable
13
+ from typing import TYPE_CHECKING, Any, BinaryIO
14
14
 
15
15
  from dissect.cstruct.bitbuffer import BitBuffer
16
16
  from dissect.cstruct.types.base import (
@@ -467,7 +467,7 @@ class UnionMetaType(StructureMetaType):
467
467
 
468
468
  # User (partial) initialization, rebuild the union
469
469
  # First user-provided field is the one used to rebuild the union
470
- arg_fields = (field._name for _, field in zip(args, cls.__fields__))
470
+ arg_fields = (field._name for _, field in zip(args, cls.__fields__, strict=False))
471
471
  kwarg_fields = (name for name in kwargs if name in cls.lookup)
472
472
  if (first_field := next(chain(arg_fields, kwarg_fields), None)) is not None:
473
473
  obj._rebuild(first_field)
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.cstruct
3
- Version: 4.6.dev8
3
+ Version: 4.7.dev1
4
4
  Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
- License: Apache License 2.0
6
+ License-Expression: Apache-2.0
7
7
  Project-URL: homepage, https://dissect.tools
8
8
  Project-URL: documentation, https://docs.dissect.tools/en/latest/projects/dissect.cstruct
9
9
  Project-URL: repository, https://github.com/fox-it/dissect.cstruct
@@ -12,14 +12,13 @@ Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Environment :: Console
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Intended Audience :: Information Technology
15
- Classifier: License :: OSI Approved
16
15
  Classifier: Operating System :: OS Independent
17
16
  Classifier: Programming Language :: Python :: 3
18
17
  Classifier: Topic :: Internet :: Log Analysis
19
18
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
19
  Classifier: Topic :: Security
21
20
  Classifier: Topic :: Utilities
22
- Requires-Python: ~=3.9
21
+ Requires-Python: >=3.10
23
22
  Description-Content-Type: text/markdown
24
23
  License-File: LICENSE
25
24
  License-File: COPYRIGHT
@@ -1,13 +1,14 @@
1
1
  [build-system]
2
- requires = ["setuptools>=65.5.0", "setuptools_scm[toml]>=6.4.0"]
2
+ requires = ["setuptools>=77.0.0", "setuptools_scm[toml]>=6.4.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dissect.cstruct"
7
7
  description = "A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy"
8
8
  readme = "README.md"
9
- requires-python = "~=3.9"
10
- license.text = "Apache License 2.0"
9
+ requires-python = ">=3.10"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE", "COPYRIGHT"]
11
12
  authors = [
12
13
  {name = "Dissect Team", email = "dissect@fox-it.com"}
13
14
  ]
@@ -16,7 +17,6 @@ classifiers = [
16
17
  "Environment :: Console",
17
18
  "Intended Audience :: Developers",
18
19
  "Intended Audience :: Information Technology",
19
- "License :: OSI Approved",
20
20
  "Operating System :: OS Independent",
21
21
  "Programming Language :: Python :: 3",
22
22
  "Topic :: Internet :: Log Analysis",
@@ -37,12 +37,33 @@ dev = [
37
37
  "typing_extensions"
38
38
  ]
39
39
 
40
+ [dependency-groups]
41
+ test = [
42
+ "pytest",
43
+ ]
44
+ lint = [
45
+ "ruff==0.13.1",
46
+ "typing_extensions",
47
+ "vermin",
48
+ ]
49
+ build = [
50
+ "build",
51
+ ]
52
+ debug = [
53
+ "ipdb",
54
+ ]
55
+ dev = [
56
+ {include-group = "test"},
57
+ {include-group = "lint"},
58
+ {include-group = "debug"},
59
+ ]
60
+
40
61
  [project.scripts]
41
62
  cstruct-stubgen = "dissect.cstruct.tools.stubgen:main"
42
63
 
43
64
  [tool.ruff]
44
65
  line-length = 120
45
- required-version = ">=0.12.0"
66
+ required-version = ">=0.13.1"
46
67
 
47
68
  [tool.ruff.format]
48
69
  docstring-code-format = true
@@ -91,9 +112,6 @@ ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM1
91
112
  known-first-party = ["dissect.cstruct"]
92
113
  known-third-party = ["dissect"]
93
114
 
94
- [tool.setuptools]
95
- license-files = ["LICENSE", "COPYRIGHT"]
96
-
97
115
  [tool.setuptools.packages.find]
98
116
  include = ["dissect.*"]
99
117
 
@@ -77,7 +77,7 @@ def test_load_init_kwargs_only() -> None:
77
77
  """
78
78
 
79
79
  # kwargs only check
80
- with pytest.raises(TypeError, match="takes from .* positional arguments but .* were given"):
80
+ with pytest.raises(TypeError, match=r"takes from .* positional arguments but .* were given"):
81
81
  cs = cstruct(cdef, ">")
82
82
 
83
83
  cs = cstruct(cdef, endian=">")
@@ -282,7 +282,7 @@ def test_conditional_parsing_error(cs: cstruct) -> None:
282
282
  };
283
283
  #endif
284
284
  """
285
- with pytest.raises(ParserError, match="line 8: unexpected token .+ENDIF"):
285
+ with pytest.raises(ParserError, match=r"line 8: unexpected token .+ENDIF"):
286
286
  cs.load(cdef)
287
287
 
288
288
  cdef = """
@@ -376,10 +376,9 @@ def test_generate_file_stub(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, cap
376
376
 
377
377
  expected = """
378
378
  # Generated by cstruct-stubgen
379
- from typing import BinaryIO, Literal, overload
379
+ from typing import BinaryIO, Literal, TypeAlias, overload
380
380
 
381
381
  import dissect.cstruct as __cs__
382
- from typing_extensions import TypeAlias
383
382
 
384
383
  class _c_structure(__cs__.cstruct):
385
384
  class Test(__cs__.Structure):
@@ -4,7 +4,7 @@ envlist = lint, py3, pypy3
4
4
  # requires if they are not available on the host system. This requires the
5
5
  # locally installed tox to have a minimum version 3.3.0. This means the names
6
6
  # of the configuration options are still according to the tox 3.x syntax.
7
- minversion = 4.4.3
7
+ minversion = 4.27.0
8
8
  # This version of virtualenv will install setuptools version 68.2.2 and pip
9
9
  # 23.3.1. These versions fully support python projects defined only through a
10
10
  # pyproject.toml file (PEP-517/PEP-518/PEP-621). This pip version also support
@@ -14,9 +14,9 @@ requires = virtualenv>=20.24.6
14
14
  [testenv]
15
15
  extras = dev
16
16
  deps =
17
- pytest
18
17
  pytest-cov
19
18
  coverage
19
+ dependency_groups = test
20
20
  commands =
21
21
  pytest --basetemp="{envtmpdir}" {posargs:--color=yes --cov=dissect --cov-report=term-missing -v tests}
22
22
  coverage report
@@ -24,28 +24,24 @@ commands =
24
24
 
25
25
  [testenv:build]
26
26
  package = skip
27
- deps =
28
- build
27
+ dependency_groups = build
29
28
  commands =
30
29
  pyproject-build
31
30
 
32
31
  [testenv:fix]
33
32
  package = skip
34
- deps =
35
- ruff==0.12.4
33
+ dependency_groups = lint
36
34
  commands =
37
- ruff format dissect tests
38
35
  ruff check --fix dissect tests
36
+ ruff format dissect tests
39
37
 
40
38
  [testenv:lint]
41
39
  package = skip
42
- deps =
43
- ruff==0.12.4
44
- vermin
40
+ dependency_groups = lint
45
41
  commands =
46
- ruff format --check dissect tests
47
42
  ruff check dissect tests
48
- vermin -t=3.9- --no-tips --lint dissect tests
43
+ ruff format --check dissect tests
44
+ vermin -t=3.10- --no-tips --lint dissect tests
49
45
 
50
46
  [testenv:docs-build]
51
47
  allowlist_externals = make