Skip to content

Commit 818be5c

Browse files
committed
chore(internal): require explicit overrides (#11)
1 parent 43c11ae commit 818be5c

9 files changed

+42
-4
lines changed

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ exclude = [
102102
".venv",
103103
".nox",
104104
]
105+
106+
reportImplicitOverride = true
107+
105108
reportImportCycles = false
106109
reportPrivateUsage = false
107110

src/orb/_base_client.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
overload,
3030
)
3131
from functools import lru_cache
32-
from typing_extensions import Literal, get_args, get_origin
32+
from typing_extensions import Literal, get_args, override, get_origin
3333

3434
import anyio
3535
import httpx
@@ -1588,6 +1588,7 @@ class OtherPlatform:
15881588
def __init__(self, name: str) -> None:
15891589
self.name = name
15901590

1591+
@override
15911592
def __str__(self) -> str:
15921593
return f"Other:{self.name}"
15931594

@@ -1649,6 +1650,7 @@ class OtherArch:
16491650
def __init__(self, name: str) -> None:
16501651
self.name = name
16511652

1653+
@override
16521654
def __str__(self) -> str:
16531655
return f"other:{self.name}"
16541656

src/orb/_client.py

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import asyncio
77
from typing import Union, Mapping
8+
from typing_extensions import override
89

910
import httpx
1011

@@ -118,10 +119,12 @@ def __init__(
118119
self.subscriptions = resources.Subscriptions(self)
119120

120121
@property
122+
@override
121123
def qs(self) -> Querystring:
122124
return Querystring(array_format="comma")
123125

124126
@property
127+
@override
125128
def auth_headers(self) -> dict[str, str]:
126129
api_key = self.api_key
127130
return {"Authorization": f"Bearer {api_key}"}
@@ -188,6 +191,7 @@ def __del__(self) -> None:
188191

189192
self.close()
190193

194+
@override
191195
def _make_status_error(
192196
self,
193197
err_msg: str,
@@ -346,10 +350,12 @@ def __init__(
346350
self.subscriptions = resources.AsyncSubscriptions(self)
347351

348352
@property
353+
@override
349354
def qs(self) -> Querystring:
350355
return Querystring(array_format="comma")
351356

352357
@property
358+
@override
353359
def auth_headers(self) -> dict[str, str]:
354360
api_key = self.api_key
355361
return {"Authorization": f"Bearer {api_key}"}
@@ -419,6 +425,7 @@ def __del__(self) -> None:
419425
except Exception:
420426
pass
421427

428+
@override
422429
def _make_status_error(
423430
self,
424431
err_msg: str,

src/orb/_models.py

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Required,
1212
TypedDict,
1313
final,
14+
override,
1415
runtime_checkable,
1516
)
1617

@@ -59,20 +60,23 @@ class BaseModel(pydantic.BaseModel):
5960
else:
6061

6162
@property
63+
@override
6264
def model_fields_set(self) -> set[str]:
6365
# a forwards-compat shim for pydantic v2
6466
return self.__fields_set__ # type: ignore
6567

6668
class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
6769
extra: Any = pydantic.Extra.allow # type: ignore
6870

71+
@override
6972
def __str__(self) -> str:
7073
# mypy complains about an invalid self arg
7174
return f'{self.__repr_name__()}({self.__repr_str__(", ")})' # type: ignore[misc]
7275

7376
# Override the 'construct' method in a way that supports recursive parsing without validation.
7477
# Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
7578
@classmethod
79+
@override
7680
def construct(
7781
cls: Type[ModelT],
7882
_fields_set: set[str] | None = None,
@@ -139,6 +143,7 @@ def construct(
139143
# a specifc pydantic version as some users may not know which
140144
# pydantic version they are currently using
141145

146+
@override
142147
def model_dump(
143148
self,
144149
*,
@@ -187,6 +192,7 @@ def model_dump(
187192
exclude_none=exclude_none,
188193
)
189194

195+
@override
190196
def model_dump_json(
191197
self,
192198
*,

src/orb/_streaming.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import json
55
from typing import TYPE_CHECKING, Any, Generic, Iterator, AsyncIterator
6+
from typing_extensions import override
67

78
import httpx
89

@@ -123,6 +124,7 @@ def data(self) -> str:
123124
def json(self) -> Any:
124125
return json.loads(self.data)
125126

127+
@override
126128
def __repr__(self) -> str:
127129
return f"ServerSentEvent(event={self.event}, data={self.data}, id={self.id}, retry={self.retry})"
128130

src/orb/_types.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
Optional,
1616
Sequence,
1717
)
18-
from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, runtime_checkable
18+
from typing_extensions import (
19+
Literal,
20+
Protocol,
21+
TypeAlias,
22+
TypedDict,
23+
override,
24+
runtime_checkable,
25+
)
1926

2027
import httpx
2128
import pydantic
@@ -119,6 +126,7 @@ def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ...
119126
def __bool__(self) -> Literal[False]:
120127
return False
121128

129+
@override
122130
def __repr__(self) -> str:
123131
return "NOT_GIVEN"
124132

src/orb/_utils/_proxy.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from abc import ABC, abstractmethod
44
from typing import Generic, TypeVar, Iterable, cast
5-
from typing_extensions import ClassVar
5+
from typing_extensions import ClassVar, override
66

77
T = TypeVar("T")
88

@@ -21,16 +21,20 @@ def __init__(self) -> None:
2121
def __getattr__(self, attr: str) -> object:
2222
return getattr(self.__get_proxied__(), attr)
2323

24+
@override
2425
def __repr__(self) -> str:
2526
return repr(self.__get_proxied__())
2627

28+
@override
2729
def __str__(self) -> str:
2830
return str(self.__get_proxied__())
2931

32+
@override
3033
def __dir__(self) -> Iterable[str]:
3134
return self.__get_proxied__().__dir__()
3235

3336
@property # type: ignore
37+
@override
3438
def __class__(self) -> type:
3539
return self.__get_proxied__().__class__
3640

src/orb/_utils/_transform.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Any, List, Mapping, TypeVar, cast
44
from datetime import date, datetime
5-
from typing_extensions import Literal, get_args, get_type_hints
5+
from typing_extensions import Literal, get_args, override, get_type_hints
66

77
from ._utils import (
88
is_list,
@@ -52,6 +52,7 @@ def __init__(
5252
self.format = format
5353
self.format_template = format_template
5454

55+
@override
5556
def __repr__(self) -> str:
5657
return f"{self.__class__.__name__}(alias='{self.alias}', format={self.format}, format_template='{self.format_template}')"
5758

src/orb/pagination.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# File generated from our OpenAPI spec by Stainless.
22

33
from typing import List, Generic, TypeVar, Optional
4+
from typing_extensions import override
45

56
from ._types import ModelT
67
from ._models import BaseModel
@@ -21,9 +22,11 @@ class SyncPage(BaseSyncPage[ModelT], BasePage[ModelT], Generic[ModelT]):
2122
data: List[ModelT]
2223
pagination_metadata: PagePaginationMetadata
2324

25+
@override
2426
def _get_page_items(self) -> List[ModelT]:
2527
return self.data
2628

29+
@override
2730
def next_page_info(self) -> Optional[PageInfo]:
2831
cursor = self.pagination_metadata.next_cursor
2932
if not cursor:
@@ -36,9 +39,11 @@ class AsyncPage(BaseAsyncPage[ModelT], BasePage[ModelT], Generic[ModelT]):
3639
data: List[ModelT]
3740
pagination_metadata: PagePaginationMetadata
3841

42+
@override
3943
def _get_page_items(self) -> List[ModelT]:
4044
return self.data
4145

46+
@override
4247
def next_page_info(self) -> Optional[PageInfo]:
4348
cursor = self.pagination_metadata.next_cursor
4449
if not cursor:

0 commit comments

Comments
 (0)