Skip to content

Commit 20f3e5c

Browse files
committed
Update notes
1 parent 48d3049 commit 20f3e5c

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

src/posit/connect/_api.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# TODO-barret-future; Piecemeal migrate everything to leverage `ApiDictEndpoint` and `ApiListEndpoint` classes.
2+
# TODO-barret-future; Merge any trailing behavior of `Active` or `ActiveList` into the new classes.
3+
14
from __future__ import annotations
25

36
import itertools
@@ -14,41 +17,30 @@
1417

1518

1619
# Design Notes:
17-
# * Perform API calls on property retrieval
20+
# * Perform API calls on property retrieval. e.g. `my_content.repository`
1821
# * Dictionary endpoints: Retrieve all attributes during init unless provided
1922
# * List endpoints: Do not retrieve until `.fetch()` is called directly. Avoids cache invalidation issues.
23+
# * While slower, all ApiListEndpoint helper methods should `.fetch()` on demand.
2024
# * Only expose methods needed for `ReadOnlyDict`.
2125
# * Ex: When inheriting from `dict`, we'd need to shut down `update`, `pop`, etc.
2226
# * Use `ApiContextProtocol` to ensure that the class has the necessary attributes for API calls.
2327
# * Inherit from `ApiCallMixin` to add all helper methods for API calls.
2428
# * Classes should write the `path` only once within its init method.
2529
# * Through regular interactions, the path should only be written once.
2630

27-
# TODO-barret; Add `.client` (a `Client` class) within `._ctx`.
28-
2931
# When making a new class,
3032
# * Use a class to define the parameters and their types
31-
# * If attaching the type info class to the parent class, start with `_`. E.g.: `_Attrs`
33+
# * If attaching the type info class to the parent class, start with `_`. E.g.: `ContentItemRepository._Attrs`
3234
# * Document all attributes like normal
3335
# * When the time comes that there are multiple attribute types, we can use overloads with full documentation and unpacking of type info class for each overload method.
3436
# * Inherit from `ApiDictEndpoint` or `ApiListEndpoint` as needed
3537
# * Init signature should be `def __init__(self, ctx: Context, path: str, /, **attrs: Jsonifiable) -> None:`
36-
# *
37-
#
38-
#
39-
# * Inherit from `ApiDictEndpoint` or `ApiListEndpoint` as needed
40-
# Use a internal
41-
42-
43-
# TODO-future?; Add type hints for the ReadOnlyDict class
44-
# ArgsT = TypeVar("ArgsT", bound="ResponseAttrs")
4538

4639

47-
class ReadOnlyDict(
48-
# Generic[ArgsT],
49-
Mapping,
50-
):
51-
# _attrs: ArgsT
40+
# This class should not have typing about the class keys as that would fix the class's typing. If
41+
# for some reason, we _know_ the keys are fixed (as we've moved on to a higher version), we can add
42+
# `Generic[AttrsT]` to the class.
43+
class ReadOnlyDict(Mapping):
5244
_attrs: ResponseAttrs
5345
"""Resource attributes passed."""
5446

@@ -145,8 +137,6 @@ def __init__(
145137

146138
super().__init__(attrs)
147139
self._ctx = ctx
148-
# TODO-barret; Look into `client` to make get,put,patch,delete calls.
149-
# self._ctx.client = client
150140
self._path = path
151141

152142
def __str__(self) -> str:

src/posit/connect/env.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,3 @@ def update(self, other=(), /, **kwargs: Optional[str]):
196196
path = f"v1/content/{self.content_guid}/environment"
197197
url = self.params.url + path
198198
self.params.session.patch(url, json=body)
199-
# TODO-barret; Q: No `super().update(**response.json())`?

0 commit comments

Comments
 (0)