type_checking: Drop some redundant None checks (#10334)

This commit is contained in:
dustinface 2022-02-21 06:30:57 +01:00 committed by GitHub
parent 48a1c26232
commit 3608d25c80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,18 +17,18 @@ else:
def is_type_List(f_type: Type) -> bool:
return (get_origin(f_type) is not None and get_origin(f_type) == list) or f_type == list
return get_origin(f_type) == list or f_type == list
def is_type_SpecificOptional(f_type) -> bool:
"""
Returns true for types such as Optional[T], but not Optional, or T.
"""
return get_origin(f_type) is not None and f_type.__origin__ == Union and get_args(f_type)[1]() is None
return get_origin(f_type) == Union and get_args(f_type)[1]() is None
def is_type_Tuple(f_type: Type) -> bool:
return (get_origin(f_type) is not None and get_origin(f_type) == tuple) or f_type == tuple
return get_origin(f_type) == tuple or f_type == tuple
def strictdataclass(cls: Any):