Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/python_introspect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/python_introspect/signature_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With include_extras=True, ParameterInfo.param_type becomes Annotated[NestedDataclass, ...] for annotated nested fields, so UnifiedParameterAnalyzer.analyze_nested() no longer recognizes it with dataclasses.is_dataclass(param_info.param_type). That regresses nested dataclass source tagging for fields that worked before this change because get_type_hints() stripped the wrapper.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

except Exception:
type_hints = inspect.get_annotations(dataclass_type, eval_str=False)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
14 changes: 13 additions & 1 deletion tests/test_signature_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Loading