Skip to content

Commit

Permalink
feat(stubs): enforce faux immutability in StubRepository.
Browse files Browse the repository at this point in the history
  • Loading branch information
BradenM committed Dec 11, 2022
1 parent 71feed2 commit a17cc5e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions micropy/stubs/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .repository_info import RepositoryInfo


@attrs.define
@attrs.define(frozen=True)
class StubRepository:
manifests: list[StubsManifest] = attrs.field(factory=list)
packages: list[StubRepositoryPackage] = attrs.field(factory=list)
Expand Down Expand Up @@ -47,7 +47,7 @@ def add_repository(self, info: RepositoryInfo) -> StubRepository:
):
continue
else:
return StubRepository(manifests=[*self.manifests, manifest])
return attrs.evolve(self, manifests=[*self.manifests, manifest])
raise ValueError(f"Failed to determine manifest format for repo: {info}")

def search(self, query: str) -> Generator[StubRepositoryPackage, None, None]:
Expand Down

0 comments on commit a17cc5e

Please sign in to comment.