diff --git a/docs/source/conf.py b/docs/source/conf.py index 350d913..2606934 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,7 +16,7 @@ project = "python-introspect" copyright = "2025, Tristan Simas" author = "Tristan Simas" -release = "0.1.7" +release = "0.1.8" version = "0.1" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 8062fdd..15cd83f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "python-introspect" -version = "0.1.7" +version = "0.1.8" description = "Pure Python introspection toolkit for function signatures, dataclasses, and type hints" readme = "README.md" requires-python = ">=3.10" diff --git a/src/python_introspect/__init__.py b/src/python_introspect/__init__.py index 8b5d93f..41bf6b8 100644 --- a/src/python_introspect/__init__.py +++ b/src/python_introspect/__init__.py @@ -9,7 +9,7 @@ type resolution for framework-specific types (lazy configs, proxies, etc.) """ -__version__ = "0.1.7" +__version__ = "0.1.8" from .signature_analyzer import ( SignatureAnalyzer, diff --git a/src/python_introspect/signature_analyzer.py b/src/python_introspect/signature_analyzer.py index 4a45d53..02c89be 100644 --- a/src/python_introspect/signature_analyzer.py +++ b/src/python_introspect/signature_analyzer.py @@ -936,7 +936,7 @@ def _analyze_dataclass(dataclass_type: type) -> Dict[str, ParameterInfo]: try: # Try to get type hints, fall back to __annotations__ if resolution fails try: - type_hints = get_type_hints(dataclass_type) + type_hints = get_type_hints(dataclass_type, include_extras=True) except Exception: type_hints = inspect.get_annotations(dataclass_type, eval_str=False) diff --git a/tests/test_init.py b/tests/test_init.py index 21c5f7e..af2d2dd 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -11,7 +11,7 @@ def test_version_available(self): """Test that __version__ is available.""" assert hasattr(python_introspect, "__version__") assert isinstance(python_introspect.__version__, str) - assert python_introspect.__version__ == "0.1.7" + assert python_introspect.__version__ == "0.1.8" def test_signature_analyzer_import(self): """Test SignatureAnalyzer is importable.""" diff --git a/tests/test_signature_analyzer.py b/tests/test_signature_analyzer.py index 9a185d8..59309c4 100644 --- a/tests/test_signature_analyzer.py +++ b/tests/test_signature_analyzer.py @@ -5,7 +5,7 @@ from enum import Enum from functools import wraps from typing import get_args -from typing import Optional, List, Dict, Any +from typing import Annotated, Optional, List, Dict, Any from python_introspect import ( SignatureAnalyzer, ParameterInfo, @@ -163,6 +163,18 @@ class Config: assert params["settings"].default_value == {} assert params["items"].is_required is False + def test_analyze_dataclass_preserves_annotated_metadata(self): + """Dataclass analysis retains metadata used by downstream projections.""" + marker = object() + + @dataclass + class Config: + shortcut: Annotated[str, marker] = "Ctrl+P" + + params = SignatureAnalyzer.analyze(Config) + + assert params["shortcut"].param_type == Annotated[str, marker] + def test_field_type_docs_use_resolved_forward_annotations(self): docs = SignatureAnalyzer._extract_field_type_docs( ForwardFieldDocumentationOwner