From 42414fb71b5701471d5f31d05036f9f74689bee0 Mon Sep 17 00:00:00 2001 From: Noa Aviel Dove Date: Mon, 21 Oct 2024 16:30:15 -0700 Subject: [PATCH] Refactor SourceRef prefix assignment --- src/azul/indexer/__init__.py | 3 +++ src/azul/plugins/__init__.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/azul/indexer/__init__.py b/src/azul/indexer/__init__.py index 5d17349c0b..3d64c4ca0f 100644 --- a/src/azul/indexer/__init__.py +++ b/src/azul/indexer/__init__.py @@ -454,6 +454,9 @@ def spec_cls(cls) -> type[SourceSpec]: spec_cls, ref_cls = get_generic_type_params(cls, SourceSpec, SourceRef) return spec_cls + def with_prefix(self, prefix: Prefix) -> Self: + return attrs.evolve(self, spec=attrs.evolve(self.spec, prefix=prefix)) + class SourcedBundleFQIDJSON(BundleFQIDJSON): source: SourceJSON diff --git a/src/azul/plugins/__init__.py b/src/azul/plugins/__init__.py index e6f9bef7a3..4f6b2c1449 100644 --- a/src/azul/plugins/__init__.py +++ b/src/azul/plugins/__init__.py @@ -636,7 +636,7 @@ def partition_source(self, prefix = Prefix.for_main_deployment(count) else: prefix = Prefix.for_lesser_deployment(count) - source = attr.evolve(source, spec=attr.evolve(source.spec, prefix=prefix)) + source = source.with_prefix(prefix) return source @abstractmethod