Skip to content

Commit

Permalink
fix frozendict for Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Nov 4, 2024
1 parent e22cfd8 commit ce55f13
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/tyro/constructors/_struct_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
import enum
import sys
import warnings
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Sequence, Union
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterable,
Sequence,
Union,
)

from typing_extensions import (
Annotated,
Expand Down Expand Up @@ -271,7 +279,10 @@ def attrs_rule(info: StructTypeInfo) -> StructConstructorSpec | None:

@registry.struct_rule
def dict_rule(info: StructTypeInfo) -> StructConstructorSpec | None:
if is_typeddict(info.type) or not isinstance(info.default, dict):
if is_typeddict(info.type) or get_origin(info.type) not in (
dict,
collections.abc.Mapping,
):
return None

if info.default in MISSING_SINGLETONS or len(info.default) == 0:
Expand Down

0 comments on commit ce55f13

Please sign in to comment.