File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1313# * Perform API calls on property retrieval
1414# * Dictionary endpoints: Retrieve all attributes during init unless provided
1515# * List endpoints: Do not retrieve until `.fetch()` is called directly. Avoids cache invalidation issues.
16+ # * Only expose methods needed for `ReadOnlyDict`.
17+ # * Ex: When inheriting from `dict`, we'd need to shut down `update`, `pop`, etc.
18+ # * Use `ApiContextProtocol` to ensure that the class has the necessary attributes for API calls.
19+ # * Inherit from `EndpointMixin` to add all helper methods for API calls.
20+ # * Classes should write the `path` only once within its init method.
21+ # * Through regular interactions, the path should only be written once.
1622
1723
1824class ApiContextProtocol (Protocol ):
1925 _ctx : Context
2026 _path : str
2127
2228
23- # TODO-future; Add type hints for the ReadOnlyDict class
29+ # TODO-future? ; Add type hints for the ReadOnlyDict class
2430# ArgsT = TypeVar("ArgsT", bound="ResponseAttrs")
2531
2632
@@ -176,6 +182,7 @@ def fetch(self) -> tuple[T, ...]:
176182 results = self ._get_api ()
177183 return tuple (self ._to_instance (result ) for result in results )
178184
185+ # Return a `tuple` to provide immutability to hint that this is a read-only collection.
179186 def __iter__ (self ) -> tuple [T , ...]:
180187 return self .fetch ()
181188
You can’t perform that action at this time.
0 commit comments