From 310392b6dc37cf9c620d0b75a88583930fafacbc Mon Sep 17 00:00:00 2001 From: Morgan McClure Date: Mon, 24 Apr 2023 12:07:54 -0700 Subject: [PATCH 1/2] help mypy figure out that 'Unset' is always falsey --- openapi_python_client/templates/types.py.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi_python_client/templates/types.py.jinja b/openapi_python_client/templates/types.py.jinja index c746db6e1..cfb990d85 100644 --- a/openapi_python_client/templates/types.py.jinja +++ b/openapi_python_client/templates/types.py.jinja @@ -1,12 +1,12 @@ """ Contains some shared types for properties """ from http import HTTPStatus -from typing import Any, BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar +from typing import Any, BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar, Literal import attr class Unset: - def __bool__(self) -> bool: + def __bool__(self) -> Literal[False]: return False From 5bfe3ec0337ba80ed227ee7ecbd8ff93ceda9975 Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Sun, 30 Apr 2023 14:07:09 -0600 Subject: [PATCH 2/2] chore: Regen tests --- end_to_end_tests/golden-record/my_test_api_client/types.py | 4 ++-- integration-tests/integration_tests/types.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/end_to_end_tests/golden-record/my_test_api_client/types.py b/end_to_end_tests/golden-record/my_test_api_client/types.py index 230efea92..599eeb9f5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/types.py @@ -1,12 +1,12 @@ """ Contains some shared types for properties """ from http import HTTPStatus -from typing import BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar import attr class Unset: - def __bool__(self) -> bool: + def __bool__(self) -> Literal[False]: return False diff --git a/integration-tests/integration_tests/types.py b/integration-tests/integration_tests/types.py index 230efea92..599eeb9f5 100644 --- a/integration-tests/integration_tests/types.py +++ b/integration-tests/integration_tests/types.py @@ -1,12 +1,12 @@ """ Contains some shared types for properties """ from http import HTTPStatus -from typing import BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar import attr class Unset: - def __bool__(self) -> bool: + def __bool__(self) -> Literal[False]: return False