Skip to content

Commit 5f2c702

Browse files
mccluremMorgan McCluredbanty
authored
feat: Better typing (mypy) support for Unset (e.g., using if statements to check type) [#714, #752]. Thanks @taasan & @mcclurem! (#752)
* help mypy figure out that 'Unset' is always falsey * chore: Regen tests --------- Co-authored-by: Morgan McClure <[email protected]> Co-authored-by: Dylan Anthony <[email protected]> Co-authored-by: Dylan Anthony <[email protected]>
1 parent fdc5038 commit 5f2c702

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

end_to_end_tests/golden-record/my_test_api_client/types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
""" Contains some shared types for properties """
22
from http import HTTPStatus
3-
from typing import BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar
3+
from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar
44

55
import attr
66

77

88
class Unset:
9-
def __bool__(self) -> bool:
9+
def __bool__(self) -> Literal[False]:
1010
return False
1111

1212

integration-tests/integration_tests/types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
""" Contains some shared types for properties """
22
from http import HTTPStatus
3-
from typing import BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar
3+
from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar
44

55
import attr
66

77

88
class Unset:
9-
def __bool__(self) -> bool:
9+
def __bool__(self) -> Literal[False]:
1010
return False
1111

1212

openapi_python_client/templates/types.py.jinja

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
""" Contains some shared types for properties """
22
from http import HTTPStatus
3-
from typing import Any, BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar
3+
from typing import Any, BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar, Literal
44

55
import attr
66

77

88
class Unset:
9-
def __bool__(self) -> bool:
9+
def __bool__(self) -> Literal[False]:
1010
return False
1111

1212

0 commit comments

Comments
 (0)