-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc45b1a
commit da94223
Showing
2 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
import re | ||
from typing import Literal, Union | ||
|
||
from typing_extensions import override | ||
|
||
from basedtyping import get_type_hints | ||
|
||
|
||
def test_get_type_hints(): | ||
result: object = None | ||
|
||
class Base: | ||
@override | ||
def __init_subclass__(cls): | ||
nonlocal result | ||
result = get_type_hints(cls) | ||
|
||
class A(Base): | ||
a: A | ||
|
||
assert result == {"a": A} | ||
|
||
|
||
def test_get_type_hints_based(): | ||
class A: | ||
a: Union[re.RegexFlag.ASCII, re.RegexFlag.DOTALL] | ||
|
||
assert get_type_hints(A) == { | ||
"a": Union[Literal[re.RegexFlag.ASCII], Literal[re.RegexFlag.DOTALL]] # noqa: PYI030 | ||
} |