Skip to content

Commit 9395d0c

Browse files
authored
Project: use self.__class__ when creating new instances (#159)
`Project` methods that create new instances have the class hardcoded, which means that calls to `update`, etc. in the internal API `Project` subclass return an external API base `Project`.
1 parent c7e63fc commit 9395d0c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

surge/projects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def list_copies(self, api_key: str = None):
240240
"""
241241
endpoint = f"{PROJECTS_ENDPOINT}/{self.id}/copies"
242242
response_json = self.get(endpoint, api_key=api_key)
243-
projects = [Project(**project_json) for project_json in response_json]
243+
projects = [self.__class__(**project_json) for project_json in response_json]
244244
return projects
245245

246246
def launch(self, api_key: str = None):
@@ -397,7 +397,7 @@ def update(
397397

398398
endpoint = f"{PROJECTS_ENDPOINT}/{self.id}"
399399
response_json = self.put(endpoint, params, api_key=api_key)
400-
return Project(**response_json)
400+
return self.__class__(**response_json)
401401

402402
def workable_by_surger(self, surger_id, api_key: str = None):
403403
"""

0 commit comments

Comments
 (0)