@@ -158,7 +158,7 @@ def _nested_dataclass_to_names(
158158 Yields each entry, like ``("a", "b", "c")`` for ``a.b.c``.
159159 """
160160
161- if isinstance (target , type ) and dataclasses . is_dataclass (target ):
161+ if dataclasses . is_dataclass (target ) and isinstance (target , type ):
162162 for field in dataclasses .fields (target ):
163163 yield from _nested_dataclass_to_names (field .type , * inner , field .name )
164164 else :
@@ -324,7 +324,7 @@ def _unrecognized_dict(
324324 continue
325325 (inner_option_field ,) = matches
326326 inner_option = inner_option_field .type
327- if isinstance (inner_option , type ) and dataclasses . is_dataclass (inner_option ):
327+ if dataclasses . is_dataclass (inner_option ) and isinstance (inner_option , type ):
328328 yield from _unrecognized_dict (
329329 settings [keystr ], inner_option , (* above , keystr )
330330 )
@@ -492,7 +492,7 @@ def convert(cls, item: Any, target: type[Any] | Any) -> object:
492492 """
493493 target , annotations = _process_annotated (target )
494494 raw_target = _get_target_raw_type (target )
495- if isinstance (raw_target , type ) and dataclasses . is_dataclass (raw_target ):
495+ if dataclasses . is_dataclass (raw_target ) and isinstance (raw_target , type ):
496496 fields = dataclasses .fields (raw_target )
497497 values = ((k .replace ("-" , "_" ), v ) for k , v in item .items ())
498498 return raw_target (
@@ -581,7 +581,7 @@ def convert_target(self, target: type[T], *prefixes: str) -> T:
581581 errors = []
582582 prep : dict [str , Any ] = {}
583583 for field in dataclasses .fields (target ): # type: ignore[arg-type]
584- if isinstance (field .type , type ) and dataclasses . is_dataclass (field .type ):
584+ if dataclasses . is_dataclass (field .type ) and isinstance (field .type , type ):
585585 try :
586586 prep [field .name ] = self .convert_target (
587587 field .type , * prefixes , field .name
0 commit comments