Skip to content

Commit

Permalink
update comment a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
benpankow committed Oct 1, 2023
1 parent 091f4ab commit e9127ce
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def is_optional(annotation: Type) -> bool:

# The Python 3.10 pipe syntax evaluates to a UnionType
# rather than a Union, so we need to check for that as well
# UnionType values are equivalent to Unions, e.g. str | None == Union[str, None]
# but the types themselves are not, e.g. type(str | None) != type(Union[str, None])
if get_origin(annotation) == UnionType:
return len(get_args(annotation)) == 2 and type(None) in get_args(annotation)

Expand Down

0 comments on commit e9127ce

Please sign in to comment.