Skip to content

Commit 161a4ca

Browse files
authored
Merge pull request #2 from OpenHCSDev/agent/preserve-dataclass-annotated-metadata
Preserve annotated dataclass metadata
2 parents c4af757 + 5daf960 commit 161a4ca

6 files changed

Lines changed: 18 additions & 6 deletions

File tree

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
project = "python-introspect"
1717
copyright = "2025, Tristan Simas"
1818
author = "Tristan Simas"
19-
release = "0.1.7"
19+
release = "0.1.8"
2020
version = "0.1"
2121

2222
# -- General configuration ---------------------------------------------------

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "python-introspect"
7-
version = "0.1.7"
7+
version = "0.1.8"
88
description = "Pure Python introspection toolkit for function signatures, dataclasses, and type hints"
99
readme = "README.md"
1010
requires-python = ">=3.10"

src/python_introspect/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
type resolution for framework-specific types (lazy configs, proxies, etc.)
1010
"""
1111

12-
__version__ = "0.1.7"
12+
__version__ = "0.1.8"
1313

1414
from .signature_analyzer import (
1515
SignatureAnalyzer,

src/python_introspect/signature_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ def _analyze_dataclass(dataclass_type: type) -> Dict[str, ParameterInfo]:
936936
try:
937937
# Try to get type hints, fall back to __annotations__ if resolution fails
938938
try:
939-
type_hints = get_type_hints(dataclass_type)
939+
type_hints = get_type_hints(dataclass_type, include_extras=True)
940940
except Exception:
941941
type_hints = inspect.get_annotations(dataclass_type, eval_str=False)
942942

tests/test_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_version_available(self):
1111
"""Test that __version__ is available."""
1212
assert hasattr(python_introspect, "__version__")
1313
assert isinstance(python_introspect.__version__, str)
14-
assert python_introspect.__version__ == "0.1.7"
14+
assert python_introspect.__version__ == "0.1.8"
1515

1616
def test_signature_analyzer_import(self):
1717
"""Test SignatureAnalyzer is importable."""

tests/test_signature_analyzer.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from enum import Enum
66
from functools import wraps
77
from typing import get_args
8-
from typing import Optional, List, Dict, Any
8+
from typing import Annotated, Optional, List, Dict, Any
99
from python_introspect import (
1010
SignatureAnalyzer,
1111
ParameterInfo,
@@ -163,6 +163,18 @@ class Config:
163163
assert params["settings"].default_value == {}
164164
assert params["items"].is_required is False
165165

166+
def test_analyze_dataclass_preserves_annotated_metadata(self):
167+
"""Dataclass analysis retains metadata used by downstream projections."""
168+
marker = object()
169+
170+
@dataclass
171+
class Config:
172+
shortcut: Annotated[str, marker] = "Ctrl+P"
173+
174+
params = SignatureAnalyzer.analyze(Config)
175+
176+
assert params["shortcut"].param_type == Annotated[str, marker]
177+
166178
def test_field_type_docs_use_resolved_forward_annotations(self):
167179
docs = SignatureAnalyzer._extract_field_type_docs(
168180
ForwardFieldDocumentationOwner

0 commit comments

Comments
 (0)