-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support PEP604 syntax
str | None
Fixes #89
- Loading branch information
Showing
3 changed files
with
79 additions
and
6 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
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 |
---|---|---|
@@ -1,11 +1,29 @@ | ||
import sys | ||
from typing import Iterable | ||
from typing import List | ||
from typing import Optional | ||
from typing import Sequence | ||
from typing import Union | ||
|
||
from fgpyo.util import types | ||
from fgpyo.util.inspect import NoneType | ||
|
||
|
||
def test_is_listlike() -> None: | ||
assert types.is_list_like(List[str]) | ||
assert types.is_list_like(Iterable[str]) | ||
assert types.is_list_like(Sequence[str]) | ||
assert not types.is_list_like(str) | ||
|
||
|
||
def test_is_optional() -> None: | ||
print(type((Union[str, NoneType]))) | ||
assert types._is_optional(Union[str, NoneType]) | ||
assert types._is_optional(Optional[str]) | ||
assert not types._is_optional(str) | ||
|
||
|
||
if sys.version_info >= (3, 10): | ||
|
||
def test_is_optional_python_310() -> None: | ||
assert types._is_optional(str | None) |