Skip to content

Commit 6164282

Browse files
dmealingclaude
andcommitted
chore(python): pre-merge simplifier pass
Five small clarity tweaks on the two commits that closed the Python ledger (fd14f33 persistence + c43e15c conformance gaps). Behavior-identical; 451/451 unit tests still green. * core_types.py: drop unused FIELD_SUBTYPE_OBJECT import. * core_types.py: lift the inline "required" validator subtype to a named VALIDATOR_SUBTYPE_REQUIRED constant — matches the metamodel-strings-as- constants discipline (Java has SUBTYPE_REQUIRED on RequiredValidator). * validation_passes.py: route the template R2 check through the already- imported OBJECT_SUBTYPE_VALUE instead of the literal "value". * object_manager.py: move the _PG_OID_* constants below the imports (PEP 8 organization — they were sandwiched mid-import-block). * query_runner.py: drop unused normalize_value / canonical_value_json imports + the `_ = ...` lines that silenced the flake — they were re-export scaffolding for a use-site that never landed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3308262 commit 6164282

4 files changed

Lines changed: 11 additions & 16 deletions

File tree

server/python/src/metaobjects/core_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
FIELD_ATTR_STORAGE,
1919
FIELD_ATTR_VALUES,
2020
FIELD_SUBTYPE_ENUM,
21-
FIELD_SUBTYPE_OBJECT,
2221
STORAGE_VALUES,
2322
)
2423
from .meta.core.field.meta_field import MetaField
@@ -440,7 +439,8 @@ def _register_subtypes(
440439
# validator.* — base + required (validates a field has a value at write time).
441440
# Sized to satisfy the cross-port corpus today; richer validator subtypes
442441
# (regex/length/numeric) can join later mirroring Java's ValidatorTypesMetaDataProvider.
443-
_VALIDATOR_SUBTYPES = (SUBTYPE_BASE, "required")
442+
VALIDATOR_SUBTYPE_REQUIRED = "required"
443+
_VALIDATOR_SUBTYPES = (SUBTYPE_BASE, VALIDATOR_SUBTYPE_REQUIRED)
444444
_register_subtypes(
445445
core_provider,
446446
TYPE_VALIDATOR,

server/python/src/metaobjects/loader/validation_passes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ def _validate_templates(root: MetaData, errors: list[MetaError]) -> None:
861861

862862
# R2 — @payloadRef must resolve to a root-level object.value
863863
payload = objects_by_name.get(payload_ref)
864-
if payload is None or payload.sub_type != "value":
864+
if payload is None or payload.sub_type != OBJECT_SUBTYPE_VALUE:
865865
errors.append(MetaError(
866866
code=ErrorCode.ERR_INVALID_TEMPLATE,
867867
message=(

server/python/src/metaobjects/runtime/object_manager.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
from collections.abc import Iterable
1212
from typing import Any, Protocol
1313

14-
15-
# pg8000 / psycopg type oids we coerce to string at extraction so the cross-port
16-
# normalization contract (BIGINT → string, NUMERIC → canonical decimal string)
17-
# is honored without leaking SQL-type awareness into the comparison layer.
18-
_PG_OID_BIGINT = 20
19-
_PG_OID_NUMERIC = 1700
20-
2114
from ..meta.meta_root import MetaRoot
2215
from ..meta.core.object.meta_object import MetaObject
2316
from ..meta.core.field.meta_field import MetaField
@@ -27,6 +20,13 @@
2720
from ..meta.persistence.source import source_constants as sc
2821

2922

23+
# pg8000 / psycopg type oids coerced to string at extraction so the cross-port
24+
# normalization contract (BIGINT → string, NUMERIC → canonical decimal string)
25+
# is honored without leaking SQL-type awareness into the comparison layer.
26+
_PG_OID_BIGINT = 20
27+
_PG_OID_NUMERIC = 1700
28+
29+
3030
# Filter shape:
3131
# {"field": "value"} → equality shortcut
3232
# {"field": {"eq": v, "gt": v, ...}} → typed ops on a field

server/python/tests/integration/query_runner.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from metaobjects.migrate.types import SchemaSnapshot
1414
from metaobjects.runtime import ObjectManager, PostgresDriver
1515

16-
from .normalization import canonical_rows_json, canonical_value_json, normalize_row, normalize_value
16+
from .normalization import canonical_rows_json, normalize_row
1717
from .postgres_container import PostgresContainer
1818
from .scenarios import QueryScenario, QuerySpec
1919

@@ -127,8 +127,3 @@ def _canonicalize_actual(actual: Any, op: str) -> str:
127127
if op == "get":
128128
return json.dumps(normalize_row(actual), sort_keys=True, separators=(",", ":"))
129129
return canonical_rows_json(actual)
130-
131-
132-
# Touch normalize_value so it's not flagged unused — re-exported for ad-hoc test use.
133-
_ = normalize_value
134-
_ = canonical_value_json

0 commit comments

Comments
 (0)