comdab 0.2.1__tar.gz → 0.3.1__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 (59) hide show
  1. {comdab-0.2.1 → comdab-0.3.1}/.github/workflows/test.yml +1 -1
  2. {comdab-0.2.1 → comdab-0.3.1}/.pre-commit-config.yaml +3 -3
  3. {comdab-0.2.1 → comdab-0.3.1}/CHANGELOG.md +13 -0
  4. {comdab-0.2.1 → comdab-0.3.1}/PKG-INFO +1 -1
  5. {comdab-0.2.1 → comdab-0.3.1}/docs/index.rst +22 -19
  6. {comdab-0.2.1 → comdab-0.3.1}/pyproject.toml +6 -3
  7. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/build.py +5 -0
  8. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/__init__.py +2 -0
  9. comdab-0.3.1/src/comdab/models/custom_type.py +22 -0
  10. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/schema.py +3 -0
  11. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/type.py +1 -2
  12. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/specific/postgresql/build.py +6 -0
  13. comdab-0.3.1/src/comdab/specific/postgresql/custom_types.py +40 -0
  14. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/specific/postgresql/functions.py +1 -1
  15. {comdab-0.2.1 → comdab-0.3.1}/tests/_mock_module.py +1 -1
  16. {comdab-0.2.1 → comdab-0.3.1}/tests/test_build.py +7 -0
  17. {comdab-0.2.1 → comdab-0.3.1}/tests/test_compare.py +16 -0
  18. {comdab-0.2.1 → comdab-0.3.1}/tests/test_models.py +10 -6
  19. {comdab-0.2.1 → comdab-0.3.1}/tests/test_specific/test_postgresql.py +127 -12
  20. comdab-0.3.1/uv.lock +658 -0
  21. comdab-0.2.1/uv.lock +0 -544
  22. {comdab-0.2.1 → comdab-0.3.1}/.github/workflows/release.yml +0 -0
  23. {comdab-0.2.1 → comdab-0.3.1}/.gitignore +0 -0
  24. {comdab-0.2.1 → comdab-0.3.1}/.python-version +0 -0
  25. {comdab-0.2.1 → comdab-0.3.1}/.readthedocs.yaml +0 -0
  26. {comdab-0.2.1 → comdab-0.3.1}/LICENSE +0 -0
  27. {comdab-0.2.1 → comdab-0.3.1}/README.md +0 -0
  28. {comdab-0.2.1 → comdab-0.3.1}/docs/Makefile +0 -0
  29. {comdab-0.2.1 → comdab-0.3.1}/docs/conf.py +0 -0
  30. {comdab-0.2.1 → comdab-0.3.1}/docs/reference.rst +0 -0
  31. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/__init__.py +0 -0
  32. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/compare.py +0 -0
  33. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/exceptions.py +0 -0
  34. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/main.py +0 -0
  35. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/base.py +0 -0
  36. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/column.py +0 -0
  37. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/constraint.py +0 -0
  38. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/function.py +0 -0
  39. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/index.py +0 -0
  40. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/sequence.py +0 -0
  41. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/table.py +0 -0
  42. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/trigger.py +0 -0
  43. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/models/view.py +0 -0
  44. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/path.py +0 -0
  45. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/py.typed +0 -0
  46. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/report.py +0 -0
  47. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/source.py +0 -0
  48. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/specific/__init__.py +0 -0
  49. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/specific/postgresql/__init__.py +0 -0
  50. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/specific/postgresql/exclude_constraints.py +0 -0
  51. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/specific/postgresql/sequences.py +0 -0
  52. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/specific/postgresql/triggers.py +0 -0
  53. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/specific/postgresql/views.py +0 -0
  54. {comdab-0.2.1 → comdab-0.3.1}/src/comdab/utils.py +0 -0
  55. {comdab-0.2.1 → comdab-0.3.1}/tests/__init__.py +0 -0
  56. {comdab-0.2.1 → comdab-0.3.1}/tests/conftest.py +0 -0
  57. {comdab-0.2.1 → comdab-0.3.1}/tests/test_main.py +0 -0
  58. {comdab-0.2.1 → comdab-0.3.1}/tests/test_specific/__init__.py +0 -0
  59. {comdab-0.2.1 → comdab-0.3.1}/tests/test_utils.py +0 -0
@@ -11,7 +11,7 @@ jobs:
11
11
  python-version:
12
12
  - "3.12"
13
13
  - "3.13"
14
- - "3.14.0-beta.3"
14
+ - "3.14.0-rc.2"
15
15
 
16
16
  steps:
17
17
  - uses: actions/checkout@v4
@@ -1,6 +1,6 @@
1
1
  repos:
2
2
  - repo: https://github.com/pre-commit/pre-commit-hooks
3
- rev: v3.2.0
3
+ rev: v6.0.0
4
4
  hooks:
5
5
  - id: trailing-whitespace
6
6
  - id: end-of-file-fixer
@@ -8,14 +8,14 @@ repos:
8
8
  - id: check-added-large-files
9
9
 
10
10
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
- rev: v0.11.11
11
+ rev: v0.15.9
12
12
  hooks:
13
13
  - id: ruff
14
14
  args: ["--fix"]
15
15
  - id: ruff-format
16
16
 
17
17
  - repo: https://github.com/RobertCraigie/pyright-python
18
- rev: v1.1.402
18
+ rev: v1.1.408
19
19
  hooks:
20
20
  - id: pyright
21
21
  hook-stage: pre-push
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.1] - 2026-04-07
9
+
10
+ ### Added
11
+
12
+ - PostgreSQL: detect & compare procedures, in addition of regular functions
13
+
14
+ ## [0.3.0] - 2025-08-12
15
+
16
+ ### Added
17
+
18
+ - PostgreSQL: detect & compare enum types, even if they are unused
19
+ (new model `ComdabCustomType`, in `ROOT.custom_types`)
20
+
8
21
  ## [0.2.1] - 2025-08-06
9
22
 
10
23
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: comdab
3
- Version: 0.2.1
3
+ Version: 0.3.1
4
4
  Summary: Compare Database Schemas
5
5
  Project-URL: Homepage, https://github.com/loic-simon/comdab
6
6
  Project-URL: Documentation, https://comdab.readthedocs.io/en/latest
@@ -105,25 +105,27 @@ to retrieve objects not natively handled by SQLALchemy.
105
105
 
106
106
  Top-level schema fields
107
107
 
108
- =========== ========== ====================================================
109
- Object Support Notes
110
- =========== ========== ====================================================
111
- Tables Yes
112
- Views Partial PostgreSQL only (temporary + materialized)
113
- Sequences Partial PostgreSQL only
114
- Functions Partial PostgreSQL only (compares reconstructed definitions)
115
- ----------- ---------- ----------------------------------------------------
116
- Columns Yes
117
- Constraints Partial All databases: PK, FK, unique & check constraints;
118
- PostgreSQL only: exclude constraints
119
- Indexes Yes
120
- Triggers Partial PostgreSQL only (compares reconstructed definitions)
121
- ----------- ---------- ----------------------------------------------------
122
- Column type Partial All SQLALchemy common types;
123
- PostgreSQL only: HSTORE, ranges, multiranges
124
- Owners No No notion of users/roles/permissions...
125
- Comments No
126
- =========== ========== ====================================================
108
+ ============ ========== =====================================================
109
+ Object Support Notes
110
+ ============ ========== =====================================================
111
+ Tables Yes
112
+ Views Partial PostgreSQL only (temporary + materialized)
113
+ Sequences Partial PostgreSQL only
114
+ Functions Partial PostgreSQL only (compares reconstructed definitions)
115
+ Custom types Partial | All databases: enums that are used (in column.type)
116
+ | PostgreSQL only: unused enums
117
+ ------------ ---------- -----------------------------------------------------
118
+ Columns Yes
119
+ Constraints Partial | All databases: PK, FK, unique & check constraints
120
+ | PostgreSQL only: exclude constraints
121
+ Indexes Yes
122
+ Triggers Partial PostgreSQL only (compares reconstructed definitions)
123
+ ------------ ---------- -----------------------------------------------------
124
+ Column type Partial | All databases: `SQLALchemy generic types`_
125
+ | PostgreSQL only: HSTORE, ranges, multiranges
126
+ Owners No No notion of users/roles/permissions...
127
+ Comments No
128
+ ============ ========== =====================================================
127
129
 
128
130
  Each object can hold non-standard / dialect-specific data in a ``extra``
129
131
  dictionary, that will be compared too (unless specifically ignored, see below).
@@ -168,3 +170,4 @@ if you want to say "every tables but ``foo``", use ``(?!foo$).*``.
168
170
  .. _sqla: https://sqlalchemy.org
169
171
  .. _SQLAlchemy connections: https://docs.sqlalchemy.org/en/stable/code/connections.html
170
172
  .. _schema reflection: https://docs.sqlalchemy.org/en/stable/code/reflecion.html
173
+ .. _SQLALchemy generic types: https://docs.sqlalchemy.org/en/stable/core/type_basics.html#generic-camelcase-types
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "comdab"
3
- version = "0.2.1"
3
+ version = "0.3.1"
4
4
  description = "Compare Database Schemas"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -27,8 +27,8 @@ Issues = "https://github.com/loic-simon/comdab/issues"
27
27
  requires = ["hatchling >= 1.26"]
28
28
  build-backend = "hatchling.build"
29
29
 
30
- [tool.uv]
31
- dev-dependencies = [
30
+ [dependency-groups]
31
+ dev = [
32
32
  "psycopg2>=2.9.10",
33
33
  "pytest>=8.4.0",
34
34
  "ruff>=0.11.11",
@@ -38,6 +38,9 @@ dev-dependencies = [
38
38
  [tool.ruff]
39
39
  line-length = 120
40
40
 
41
+ [tool.ruff.lint]
42
+ select = ["E", "F", "UP", "B", "SIM", "I"]
43
+
41
44
  [tool.pyright]
42
45
  typeCheckingMode = "strict"
43
46
  venvPath = "."
@@ -13,6 +13,7 @@ from comdab.models.constraint import (
13
13
  ComdabPrimaryKeyConstraint,
14
14
  ComdabUniqueConstraint,
15
15
  )
16
+ from comdab.models.custom_type import ComdabCustomType
16
17
  from comdab.models.function import ComdabFunction
17
18
  from comdab.models.index import ComdabIndex
18
19
  from comdab.models.schema import ComdabSchema
@@ -57,6 +58,7 @@ class ComdabBuilder:
57
58
  views=dict_by_name(self.generate_views(sa_metadata)),
58
59
  sequences=dict_by_name(self.generate_sequences(sa_metadata)),
59
60
  functions=dict_by_name(self.generate_functions(sa_metadata)),
61
+ custom_types=dict_by_name(self.generate_custom_types(sa_metadata)),
60
62
  extra={str(key): val for key, val in sa_metadata.info.items()},
61
63
  )
62
64
 
@@ -85,6 +87,9 @@ class ComdabBuilder:
85
87
  def generate_functions(self, sa_metadata: schema.MetaData) -> Iterator[ComdabFunction]:
86
88
  yield from () # No database-agnostic implementation
87
89
 
90
+ def generate_custom_types(self, sa_metadata: schema.MetaData) -> Iterator[ComdabCustomType]:
91
+ yield from () # No database-agnostic implementation
92
+
88
93
  # Level 2
89
94
 
90
95
  def generate_columns(self, sa_table: schema.Table) -> Iterator[ComdabColumn]:
@@ -6,6 +6,7 @@ from comdab.models.constraint import (
6
6
  ComdabPrimaryKeyConstraint,
7
7
  ComdabUniqueConstraint,
8
8
  )
9
+ from comdab.models.custom_type import ComdabCustomType
9
10
  from comdab.models.function import ComdabFunction
10
11
  from comdab.models.index import ComdabIndex
11
12
  from comdab.models.schema import ROOT, ComdabSchema
@@ -18,6 +19,7 @@ from comdab.models.view import ComdabView
18
19
  __all__ = (
19
20
  "ComdabCheckConstraint",
20
21
  "ComdabColumn",
22
+ "ComdabCustomType",
21
23
  "ComdabExcludeConstraint",
22
24
  "ComdabForeignKeyConstraint",
23
25
  "ComdabFunction",
@@ -0,0 +1,22 @@
1
+ from typing import Any
2
+
3
+ from pydantic import Field
4
+
5
+ from comdab.models.base import ComdabModel
6
+ from comdab.path import ComdabPath, dict_of_paths, terminal_path
7
+
8
+
9
+ class ComdabCustomType(ComdabModel, frozen=True):
10
+ """A database custom type (only Enums supported).
11
+
12
+ Even types not used in any column are listed here.
13
+ """
14
+
15
+ name: str
16
+ values: list[str]
17
+ extra: dict[str, Any] = Field(default_factory=dict)
18
+
19
+ class Path(ComdabPath):
20
+ name = terminal_path()
21
+ values = terminal_path()
22
+ extra = dict_of_paths(ComdabPath)
@@ -3,6 +3,7 @@ from typing import Any
3
3
  from pydantic import Field
4
4
 
5
5
  from comdab.models.base import ComdabModel
6
+ from comdab.models.custom_type import ComdabCustomType
6
7
  from comdab.models.function import ComdabFunction
7
8
  from comdab.models.sequence import ComdabSequence
8
9
  from comdab.models.table import ComdabTable
@@ -20,6 +21,7 @@ class ComdabSchema(ComdabModel, frozen=True):
20
21
  views: dict[str, ComdabView]
21
22
  sequences: dict[str, ComdabSequence]
22
23
  functions: dict[str, ComdabFunction]
24
+ custom_types: dict[str, ComdabCustomType]
23
25
  extra: dict[str, Any] = Field(default_factory=dict)
24
26
 
25
27
  class Path(ComdabPath):
@@ -27,6 +29,7 @@ class ComdabSchema(ComdabModel, frozen=True):
27
29
  views = dict_of_paths(ComdabView.Path)
28
30
  sequences = dict_of_paths(ComdabSequence.Path)
29
31
  functions = dict_of_paths(ComdabFunction.Path)
32
+ custom_types = dict_of_paths(ComdabCustomType.Path)
30
33
  extra = dict_of_paths(ComdabPath)
31
34
 
32
35
 
@@ -1,7 +1,6 @@
1
- from typing import Any, get_args
1
+ from typing import Any, Unpack, get_args
2
2
 
3
3
  from pydantic import ConfigDict, Field
4
- from typing_extensions import Unpack
5
4
 
6
5
  from comdab.models.base import ComdabModel
7
6
  from comdab.path import (
@@ -8,11 +8,13 @@ from sqlalchemy.dialects.postgresql import HSTORE, ranges
8
8
  from comdab.build import ComdabBuilder
9
9
  from comdab.exceptions import UnhandledTypeError
10
10
  from comdab.models.constraint import ComdabConstraint, ComdabExcludeConstraint
11
+ from comdab.models.custom_type import ComdabCustomType
11
12
  from comdab.models.function import ComdabFunction
12
13
  from comdab.models.sequence import ComdabSequence
13
14
  from comdab.models.trigger import ComdabTrigger
14
15
  from comdab.models.type import ComdabType, ComdabTypes
15
16
  from comdab.models.view import ComdabView
17
+ from comdab.specific.postgresql.custom_types import get_postgresql_custom_types
16
18
  from comdab.specific.postgresql.exclude_constraints import get_postgresql_exclude_constraints_by_table
17
19
  from comdab.specific.postgresql.functions import get_postgresql_functions
18
20
  from comdab.specific.postgresql.sequences import get_postgresql_sequences
@@ -35,6 +37,10 @@ class ComdabPostgreSQLBuilder(ComdabBuilder):
35
37
  yield from super().generate_functions(sa_metadata)
36
38
  yield from get_postgresql_functions(self.source)
37
39
 
40
+ def generate_custom_types(self, sa_metadata: MetaData) -> Iterator[ComdabCustomType]:
41
+ yield from super().generate_custom_types(sa_metadata)
42
+ yield from get_postgresql_custom_types(self.source)
43
+
38
44
  # Level 2
39
45
 
40
46
  @cached_property
@@ -0,0 +1,40 @@
1
+ from typing import NamedTuple
2
+
3
+ from comdab.models.custom_type import ComdabCustomType
4
+ from comdab.source import ComdabSource
5
+ from comdab.utils import typed_sql
6
+
7
+
8
+ class _CustomTypesQuery(NamedTuple):
9
+ typname: str
10
+ values: list[str]
11
+
12
+
13
+ _CUSTOM_TYPES_QUERY = typed_sql[_CustomTypesQuery](
14
+ """--sql
15
+
16
+ SELECT
17
+ typ.typname,
18
+ ARRAY_AGG(enum.enumlabel ORDER BY enum.enumsortorder) AS values
19
+ FROM pg_catalog.pg_type typ -- Type
20
+ JOIN pg_catalog.pg_namespace nsp ON typ.typnamespace = nsp.oid -- Type schema
21
+ LEFT OUTER JOIN pg_catalog.pg_enum enum ON enum.enumtypid = typ.oid -- Enum values
22
+ WHERE nsp.nspname = :schema_name
23
+ AND typ.typtype = 'e' -- TODO: handle other kind of custom types?
24
+ GROUP BY typ.oid;
25
+ """,
26
+ )
27
+
28
+
29
+ def get_postgresql_custom_types(source: ComdabSource) -> list[ComdabCustomType]:
30
+ result = source.connection.execute(
31
+ _CUSTOM_TYPES_QUERY,
32
+ {"schema_name": source.schema_name},
33
+ )
34
+ return [
35
+ ComdabCustomType(
36
+ name=row.typname,
37
+ values=row.values,
38
+ )
39
+ for row in result.t
40
+ ]
@@ -19,7 +19,7 @@ _FUNCTIONS_QUERY = typed_sql[_FunctionsQuery](
19
19
  JOIN pg_catalog.pg_namespace nsp ON nsp.oid = pro.pronamespace -- Function schema
20
20
  JOIN pg_catalog.pg_language lan ON lan.oid = pro.prolang -- Function implementation language
21
21
  WHERE nsp.nspname = :schema_name
22
- AND pro.prokind = 'f' -- TODO: handle procedure/aggregate/window functions?
22
+ AND pro.prokind IN ('f', 'p') -- TODO: handle aggregate/window functions?
23
23
  AND lan.lanname != 'c';
24
24
  """,
25
25
  )
@@ -2,6 +2,6 @@ from functools import lru_cache
2
2
  from unittest.mock import Mock
3
3
 
4
4
 
5
- @lru_cache()
5
+ @lru_cache
6
6
  def __getattr__(item: object) -> Mock:
7
7
  return Mock()
@@ -80,6 +80,7 @@ def test_empty_metadata(meta: MetaData) -> None:
80
80
  views={},
81
81
  sequences={},
82
82
  functions={},
83
+ custom_types={},
83
84
  )
84
85
 
85
86
 
@@ -121,6 +122,7 @@ def test_basic(meta: MetaData) -> None:
121
122
  views={},
122
123
  sequences={},
123
124
  functions={},
125
+ custom_types={},
124
126
  extra={"hello": 3, "bye": 2},
125
127
  )
126
128
 
@@ -184,6 +186,7 @@ def test_column_attributes(meta: MetaData) -> None:
184
186
  views={},
185
187
  sequences={},
186
188
  functions={},
189
+ custom_types={},
187
190
  )
188
191
 
189
192
 
@@ -342,6 +345,7 @@ def test_constraints(meta: MetaData) -> None:
342
345
  views={},
343
346
  sequences={},
344
347
  functions={},
348
+ custom_types={},
345
349
  )
346
350
 
347
351
 
@@ -397,6 +401,7 @@ def test_indexes(meta: MetaData) -> None:
397
401
  views={},
398
402
  sequences={},
399
403
  functions={},
404
+ custom_types={},
400
405
  )
401
406
 
402
407
 
@@ -499,6 +504,7 @@ def test_types(meta: MetaData) -> None:
499
504
  views={},
500
505
  sequences={},
501
506
  functions={},
507
+ custom_types={},
502
508
  )
503
509
 
504
510
 
@@ -550,4 +556,5 @@ def test_unknown_types(meta: MetaData) -> None:
550
556
  views={},
551
557
  sequences={},
552
558
  functions={},
559
+ custom_types={},
553
560
  )
@@ -18,6 +18,7 @@ from comdab.models import (
18
18
  ComdabUniqueConstraint,
19
19
  ComdabView,
20
20
  )
21
+ from comdab.models.custom_type import ComdabCustomType
21
22
  from comdab.path import ComdabPath
22
23
  from comdab.report import ComdabReport
23
24
 
@@ -26,6 +27,7 @@ EMPTY_SCHEMA = ComdabSchema(
26
27
  views={},
27
28
  sequences={},
28
29
  functions={},
30
+ custom_types={},
29
31
  )
30
32
 
31
33
  FULL_SCHEMA = ComdabSchema(
@@ -125,6 +127,10 @@ FULL_SCHEMA = ComdabSchema(
125
127
  ),
126
128
  "other_func": ComdabFunction(name="other_func", definition="CREATE OR REPLACE OTHER FUNCTION..."),
127
129
  },
130
+ custom_types={
131
+ "my_enum": ComdabCustomType(name="my_enum", values=["one", "two"]),
132
+ "my_enum_2": ComdabCustomType(name="my_enum_2", values=["Three (3)", "FOUR"]),
133
+ },
128
134
  extra={
129
135
  "extra1": "foo",
130
136
  "extra2": {"key1": True, "key2": False},
@@ -149,6 +155,8 @@ def test_empty_vs_full() -> None:
149
155
  ComdabReport("error", ROOT.sequences.right_only, {}, {"seq2": FULL_SCHEMA.sequences["seq2"]}),
150
156
  ComdabReport("error", ROOT.functions.right_only, {}, {"my_func": FULL_SCHEMA.functions["my_func"]}),
151
157
  ComdabReport("error", ROOT.functions.right_only, {}, {"other_func": FULL_SCHEMA.functions["other_func"]}),
158
+ ComdabReport("error", ROOT.custom_types.right_only, {}, {"my_enum": FULL_SCHEMA.custom_types["my_enum"]}),
159
+ ComdabReport("error", ROOT.custom_types.right_only, {}, {"my_enum_2": FULL_SCHEMA.custom_types["my_enum_2"]}),
152
160
  ComdabReport("error", ROOT.extra.right_only, {}, {"extra1": FULL_SCHEMA.extra["extra1"]}),
153
161
  ComdabReport("error", ROOT.extra.right_only, {}, {"extra2": FULL_SCHEMA.extra["extra2"]}),
154
162
  ]
@@ -161,6 +169,8 @@ def test_empty_vs_full() -> None:
161
169
  ComdabReport("error", ROOT.sequences.left_only, {"seq2": FULL_SCHEMA.sequences["seq2"]}, {}),
162
170
  ComdabReport("error", ROOT.functions.left_only, {"my_func": FULL_SCHEMA.functions["my_func"]}, {}),
163
171
  ComdabReport("error", ROOT.functions.left_only, {"other_func": FULL_SCHEMA.functions["other_func"]}, {}),
172
+ ComdabReport("error", ROOT.custom_types.left_only, {"my_enum": FULL_SCHEMA.custom_types["my_enum"]}, {}),
173
+ ComdabReport("error", ROOT.custom_types.left_only, {"my_enum_2": FULL_SCHEMA.custom_types["my_enum_2"]}, {}),
164
174
  ComdabReport("error", ROOT.extra.left_only, {"extra1": FULL_SCHEMA.extra["extra1"]}, {}),
165
175
  ComdabReport("error", ROOT.extra.left_only, {"extra2": FULL_SCHEMA.extra["extra2"]}, {}),
166
176
  ]
@@ -254,6 +264,8 @@ def test_rules_empty_vs_full() -> None:
254
264
  ComdabReport("error", ROOT.sequences.right_only, {}, {"seq2": FULL_SCHEMA.sequences["seq2"]}),
255
265
  ComdabReport("error", ROOT.functions.right_only, {}, {"my_func": FULL_SCHEMA.functions["my_func"]}),
256
266
  ComdabReport("error", ROOT.functions.right_only, {}, {"other_func": FULL_SCHEMA.functions["other_func"]}),
267
+ ComdabReport("error", ROOT.custom_types.right_only, {}, {"my_enum": FULL_SCHEMA.custom_types["my_enum"]}),
268
+ ComdabReport("error", ROOT.custom_types.right_only, {}, {"my_enum_2": FULL_SCHEMA.custom_types["my_enum_2"]}),
257
269
  ComdabReport("error", ROOT.extra.right_only, {}, {"extra1": FULL_SCHEMA.extra["extra1"]}),
258
270
  ComdabReport("error", ROOT.extra.right_only, {}, {"extra2": FULL_SCHEMA.extra["extra2"]}),
259
271
  ]
@@ -266,6 +278,8 @@ def test_rules_empty_vs_full() -> None:
266
278
  ComdabReport("warning", ROOT.sequences.right_only, {}, {"seq2": FULL_SCHEMA.sequences["seq2"]}),
267
279
  ComdabReport("warning", ROOT.functions.right_only, {}, {"my_func": FULL_SCHEMA.functions["my_func"]}),
268
280
  ComdabReport("warning", ROOT.functions.right_only, {}, {"other_func": FULL_SCHEMA.functions["other_func"]}),
281
+ ComdabReport("warning", ROOT.custom_types.right_only, {}, {"my_enum": FULL_SCHEMA.custom_types["my_enum"]}),
282
+ ComdabReport("warning", ROOT.custom_types.right_only, {}, {"my_enum_2": FULL_SCHEMA.custom_types["my_enum_2"]}),
269
283
  ComdabReport("warning", ROOT.extra.right_only, {}, {"extra1": FULL_SCHEMA.extra["extra1"]}),
270
284
  ComdabReport("warning", ROOT.extra.right_only, {}, {"extra2": FULL_SCHEMA.extra["extra2"]}),
271
285
  ]
@@ -278,6 +292,8 @@ def test_rules_empty_vs_full() -> None:
278
292
  ComdabReport("warning", ROOT.views.right_only, {}, {"_table1_mat": FULL_SCHEMA.views["_table1_mat"]}),
279
293
  ComdabReport("error", ROOT.functions.right_only, {}, {"my_func": FULL_SCHEMA.functions["my_func"]}),
280
294
  ComdabReport("error", ROOT.functions.right_only, {}, {"other_func": FULL_SCHEMA.functions["other_func"]}),
295
+ ComdabReport("error", ROOT.custom_types.right_only, {}, {"my_enum": FULL_SCHEMA.custom_types["my_enum"]}),
296
+ ComdabReport("error", ROOT.custom_types.right_only, {}, {"my_enum_2": FULL_SCHEMA.custom_types["my_enum_2"]}),
281
297
  ComdabReport("error", ROOT.extra.right_only, {}, {"extra1": FULL_SCHEMA.extra["extra1"]}),
282
298
  ComdabReport("error", ROOT.extra.right_only, {}, {"extra2": FULL_SCHEMA.extra["extra2"]}),
283
299
  ]
@@ -82,7 +82,7 @@ class TestPathsConsistency:
82
82
  try:
83
83
  Path = cast(type[ComdabPath], base_schema_field.Path) # pyright: ignore
84
84
  except AttributeError:
85
- raise AssertionError(f"Missing Path attribute for ComdabModel: {base_schema_field}")
85
+ raise AssertionError(f"Missing Path attribute for ComdabModel: {base_schema_field}") from None
86
86
  assert path_type is Path, (
87
87
  f"{base_model.__name__}.Path.{name} describes a {path_type}, expected {base_schema_field}.Path!"
88
88
  )
@@ -102,12 +102,14 @@ class TestPathsConsistency:
102
102
  try:
103
103
  Path = cast(type[ComdabPath], base_value_ann.Path) # pyright: ignore
104
104
  except AttributeError:
105
- raise AssertionError(f"Missing Path attribute for ComdabModel: {base_value_ann}")
105
+ raise AssertionError(f"Missing Path attribute for ComdabModel: {base_value_ann}") from None
106
106
  assert get_origin(path_type) is ComdabPathDict, (
107
- f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary of {base_schema_field}.Path!"
107
+ f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary "
108
+ f"of {base_schema_field}.Path!"
108
109
  )
109
110
  assert get_args(path_type)[0] is Path, (
110
- f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary of {base_schema_field}.Path!"
111
+ f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary "
112
+ f"of {base_schema_field}.Path!"
111
113
  )
112
114
 
113
115
  # Then validate child schema
@@ -117,10 +119,12 @@ class TestPathsConsistency:
117
119
  else:
118
120
  # Schema field is a dict of non-schemas: check the path field is a dict of terminal ComdabPaths
119
121
  assert get_origin(path_type) is ComdabPathDict, (
120
- f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary of ComdabPath!"
122
+ f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary "
123
+ "of ComdabPath!"
121
124
  )
122
125
  assert get_args(path_type)[0] is ComdabPath, (
123
- f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary of ComdabPath!"
126
+ f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary "
127
+ "of ComdabPath!"
124
128
  )
125
129
 
126
130
  case _: