Skip to content

Commit

Permalink
Delint.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkw31 committed Nov 14, 2024
1 parent 41ea802 commit ddc38a4
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions softpack_core/schemas/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,7 @@ def delete(cls, name: str, path: str) -> DeleteResponse: # type: ignore
tree_oid = artifacts.delete_environment(name, path)
artifacts.commit_and_push(tree_oid, "delete environment")

index = cls.env_index_from_path(str(Path(path, name)))
if index is not None:
del Environment.environments[index]
Environment.update_cache(Path(path, name))

return DeleteEnvironmentSuccess(
message="Successfully deleted the environment"
Expand Down Expand Up @@ -964,20 +962,9 @@ async def write_artifacts(
error="".join(format_exception_only(type(e), e))
)

@classmethod
def env_index_from_path(cls, folder_path: str) -> Optional[int]:
"""Return the index of a folder_path from the list of environments."""
return next(
(
i
for i, env in enumerate(Environment.environments)
if str(env.full_path()) == folder_path
),
None,
)

@classmethod
def update_cache(cls, folder_path: str | Path) -> None:
"""Regenerate the cached environment specified by the path."""
index = cls.env_index_from_path(str(folder_path))
path = Path(folder_path)
env = Environment.get_env(path.parent, path.name)
Expand All @@ -990,6 +977,18 @@ def update_cache(cls, folder_path: str | Path) -> None:
else:
del Environment.environments[index]

@classmethod
def env_index_from_path(cls, folder_path: str) -> Optional[int]:
"""Return the index of a folder_path from the list of environments."""
return next(
(
i
for i, env in enumerate(Environment.environments)
if str(env.full_path()) == folder_path
),
None,
)

@classmethod
async def update_from_module(
cls, file: bytes, module_path: str, environment_path: str
Expand Down

0 comments on commit ddc38a4

Please sign in to comment.