diff --git a/packages/testing/src/consensus_testing/test_fixtures/networking_codec.py b/packages/testing/src/consensus_testing/test_fixtures/networking_codec.py index 7754216e6..01ac012aa 100644 --- a/packages/testing/src/consensus_testing/test_fixtures/networking_codec.py +++ b/packages/testing/src/consensus_testing/test_fixtures/networking_codec.py @@ -1,7 +1,7 @@ """Networking codec test fixture for wire-format conformance testing.""" from collections.abc import Callable -from typing import Annotated, ClassVar, Final, Literal, Union +from typing import Annotated, ClassVar, Final, Literal from pydantic import Field @@ -699,20 +699,18 @@ def attempt_decode(self) -> Exception | None: NetworkingCodec = Annotated[ - Union[ - VarintRoundtrip, - GossipTopicRoundtrip, - GossipMessageIdentifier, - GossipsubRpcRoundtrip, - ReqRespRequestRoundtrip, - ReqRespResponseRoundtrip, - ReqRespResponseStream, - EnrRoundtrip, - PeerIdentifierDerivation, - SnappyBlockRoundtrip, - SnappyFrameRoundtrip, - DecodeFailure, - ], + VarintRoundtrip + | GossipTopicRoundtrip + | GossipMessageIdentifier + | GossipsubRpcRoundtrip + | ReqRespRequestRoundtrip + | ReqRespResponseRoundtrip + | ReqRespResponseStream + | EnrRoundtrip + | PeerIdentifierDerivation + | SnappyBlockRoundtrip + | SnappyFrameRoundtrip + | DecodeFailure, Field(discriminator="kind"), ] """Discriminated union of every networking codec case under test.""" diff --git a/packages/testing/src/consensus_testing/test_fixtures/slot_clock.py b/packages/testing/src/consensus_testing/test_fixtures/slot_clock.py index b2c396f0a..406a392d2 100644 --- a/packages/testing/src/consensus_testing/test_fixtures/slot_clock.py +++ b/packages/testing/src/consensus_testing/test_fixtures/slot_clock.py @@ -1,6 +1,6 @@ """Slot clock test fixture for timing conformance testing.""" -from typing import Annotated, ClassVar, Literal, Union +from typing import Annotated, ClassVar, Literal from pydantic import Field @@ -146,7 +146,7 @@ def run(self) -> TotalIntervalsOutput: SlotClockOperation = Annotated[ - Union[FromUnixTime, FromSlot, CurrentSlot, CurrentInterval, TotalIntervals], + FromUnixTime | FromSlot | CurrentSlot | CurrentInterval | TotalIntervals, Field(discriminator="kind"), ] """Discriminated union of every slot clock conversion under test.""" diff --git a/packages/testing/src/consensus_testing/test_types/step_types.py b/packages/testing/src/consensus_testing/test_types/step_types.py index b42530df2..cb449eb4a 100644 --- a/packages/testing/src/consensus_testing/test_types/step_types.py +++ b/packages/testing/src/consensus_testing/test_types/step_types.py @@ -1,6 +1,6 @@ """Step types for fork choice tests: author-facing inputs and emitted results.""" -from typing import Annotated, Any, Literal, Union +from typing import Annotated, Any, Literal from pydantic import Field, field_serializer, model_validator @@ -173,7 +173,7 @@ class GossipAggregatedAttestationStep(BaseForkChoiceStep): # Discriminated union type for all fork choice steps ForkChoiceStep = Annotated[ - Union[TickStep, BlockStep, AttestationStep, GossipAggregatedAttestationStep], + TickStep | BlockStep | AttestationStep | GossipAggregatedAttestationStep, Field(discriminator="step_type"), ] @@ -281,11 +281,9 @@ class FilledGossipAggregatedAttestationStep(BaseFilledStep): # Discriminated union type for all emitted fork choice steps FilledForkChoiceStep = Annotated[ - Union[ - FilledTickStep, - FilledBlockStep, - FilledAttestationStep, - FilledGossipAggregatedAttestationStep, - ], + FilledTickStep + | FilledBlockStep + | FilledAttestationStep + | FilledGossipAggregatedAttestationStep, Field(discriminator="step_type"), ]