Skip to content

Commit da0bb45

Browse files
committed
Centralize parameter owner authority
1 parent b38e3f1 commit da0bb45

6 files changed

Lines changed: 29 additions & 7 deletions

File tree

‎pyproject.toml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "objectstate"
7-
version = "1.1.3"
7+
version = "1.1.4"
88
description = "Generic lazy dataclass configuration framework with dual-axis inheritance and contextvars-based resolution"
99
authors = [{name = "Tristan Simas", email = "tristan.simas@mail.mcgill.ca"}]
1010
license = {text = "MIT"}
@@ -50,6 +50,10 @@ Issues = "https://github.com/OpenHCSDev/objectstate/issues"
5050

5151
[tool.hatch.build.targets.wheel]
5252
packages = ["src/objectstate"]
53+
core-metadata-version = "2.4"
54+
55+
[tool.hatch.build.targets.sdist]
56+
core-metadata-version = "2.4"
5357

5458
[tool.pytest.ini_options]
5559
testpaths = ["tests"]

‎src/objectstate/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136

137137
# Field access authority
138138
from objectstate.field_access import DataclassFieldAccess, DottedFieldPath, FieldAccessError
139+
from objectstate.parameter_owner import ParameterOwner
139140
from objectstate.subfield_semantics import (
140141
MISSING,
141142
MissingValue,
@@ -202,6 +203,7 @@
202203
'DataclassFieldAccess',
203204
'DottedFieldPath',
204205
'FieldAccessError',
206+
'ParameterOwner',
205207
'MISSING',
206208
'MissingValue',
207209
'ObjectStateSubfieldSemantic',
@@ -214,7 +216,7 @@
214216
'ObjectStateEditSession',
215217
]
216218

217-
__version__ = "1.1.3"
219+
__version__ = "1.1.4"
218220
__author__ = 'OpenHCS Team'
219221
__description__ = 'Generic configuration framework for lazy dataclass resolution'
220222

‎src/objectstate/object_state.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from dataclasses import fields as dataclass_fields
1313
from dataclasses import is_dataclass
1414
from types import FunctionType
15-
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TypeAlias
15+
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
1616

1717
from objectstate.field_access import DataclassFieldAccess, DottedFieldPath
1818
from objectstate.object_state_metadata import (
@@ -21,6 +21,7 @@
2121
ObjectStateMetadataStore,
2222
)
2323
from objectstate.object_state_registry import ObjectStateRegistry
24+
from objectstate.parameter_owner import ParameterOwner
2425
from objectstate.subfield_semantics import (
2526
MISSING,
2627
ObjectStateSubfieldSemanticIndex,
@@ -32,8 +33,6 @@
3233

3334
logger = logging.getLogger(__name__)
3435

35-
ParameterOwner: TypeAlias = type | Callable[..., Any]
36-
3736
class FieldProxy:
3837
"""Type-safe proxy for accessing ObjectState fields via dotted attribute syntax.
3938

‎src/objectstate/object_state_registry.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import copy
1010

1111
from objectstate.object_state_metadata import ObjectStateMetadataStore
12+
from objectstate.parameter_owner import ParameterOwner
1213
from objectstate.snapshot_model import Snapshot, StateSnapshot, Timeline
1314
from objectstate.time_travel_profile import TimeTravelProfiler
1415

@@ -17,8 +18,6 @@
1718

1819
TimeTravelStateEntry: TypeAlias = Tuple[str, 'ObjectState']
1920
TimeTravelCompleteCallback: TypeAlias = Callable[[List[TimeTravelStateEntry], Optional[str]], None]
20-
ParameterOwner: TypeAlias = type | Callable[..., Any]
21-
2221
logger = logging.getLogger(__name__)
2322

2423

‎src/objectstate/parameter_owner.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Canonical declaration owner type used by ObjectState path metadata."""
2+
3+
from collections.abc import Callable
4+
from typing import Any, TypeAlias
5+
6+
ParameterOwner: TypeAlias = type | Callable[..., Any]
7+
"""Type or callable declaration that owns an extracted parameter."""

‎tests/test_parameter_owner.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Tests for the canonical ObjectState parameter-owner declaration."""
2+
3+
from typing import get_type_hints
4+
5+
from objectstate import ObjectState, ParameterOwner
6+
from objectstate.object_state_registry import DeferredFieldInvalidation
7+
8+
9+
def test_objectstate_surfaces_share_parameter_owner_authority() -> None:
10+
assert get_type_hints(ObjectState.type_for_path)["return"] == ParameterOwner
11+
assert get_type_hints(DeferredFieldInvalidation)["changed_type"] == ParameterOwner

0 commit comments

Comments
 (0)