Skip to content

Commit 96feb7a

Browse files
committed
Be sure to retrieve data before init'ing
1 parent 15f854a commit 96feb7a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/posit/connect/content.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ def _assert_guid(guid: str):
5252

5353
# ContentItem Repository uses a PATCH method, not a PUT for updating.
5454
class _ContentItemRepository(_Resource):
55-
def update(self, **attributes): # type: ignore[reportIncompatibleMethodOverride]
55+
def update(self, **attributes):
5656
response = self._ctx.client.patch(self._path, json=attributes)
5757
result = response.json()
58-
super().update(**result)
58+
# # Calling this method will call `_Resource.update` which will try to PUT to the path.
59+
# super().update(**result)
60+
# Instead, update the dict directly.
61+
dict.update(self, **result)
5962

6063

61-
class ContentItemRepository(ResourceP):
64+
class ContentItemRepository(ResourceP, Protocol):
6265
"""
6366
Content items GitHub repository information.
6467
@@ -217,9 +220,13 @@ def oauth(self) -> ContentItemOAuth:
217220
@property
218221
def repository(self) -> ContentItemRepository | None:
219222
try:
223+
path = f"v1/content/{self['guid']}/repository"
224+
response = self._ctx.client.get(path)
225+
result = response.json()
220226
return _ContentItemRepository(
221227
self._ctx,
222-
f"v1/content/{self['guid']}/repository",
228+
path,
229+
**result,
223230
)
224231
except ClientError:
225232
return None

src/posit/connect/resources.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
TYPE_CHECKING,
88
Any,
99
Iterable,
10-
Protocol,
1110
Sequence,
1211
)
1312

0 commit comments

Comments
 (0)