Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
v-chen_data committed Sep 27, 2024
1 parent dcf4569 commit 5edb5a5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/utils/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import contextlib
import inspect
import pickle
from typing import Any, Optional
from typing import Any, Optional, get_type_hints

import pytest

Expand All @@ -16,10 +16,11 @@ def create_exception_object(
):

def get_init_annotations(cls: type):
if hasattr(inspect, 'get_annotations'):
return inspect.get_annotations(cls.__init__)
else:
return getattr(cls.__init__, '__annotations__', {})
try:
return get_type_hints(cls.__init__)
except (AttributeError, TypeError):
# Handle cases where __init__ does not exist or has no annotations
return {}

# First, try to get annotations from the class itself
required_args = get_init_annotations(exception_class)
Expand Down

0 comments on commit 5edb5a5

Please sign in to comment.