Skip to content
Snippets Groups Projects
Commit 54db8d55 authored by Neda Moeini's avatar Neda Moeini
Browse files

Fix mypy errors.

parent 4f78e77c
No related branches found
No related tags found
No related merge requests found
"""Layer 2 Circuit product block.""" """Layer 2 Circuit product block."""
from collections.abc import Sequence
from typing import Annotated, TypeVar from typing import Annotated, TypeVar
from annotated_types import Len from annotated_types import Len
...@@ -51,7 +52,7 @@ Layer2CircuitSideBlockType = TypeVar( ...@@ -51,7 +52,7 @@ Layer2CircuitSideBlockType = TypeVar(
) )
Layer2CircuitSides = Annotated[ Layer2CircuitSides = Annotated[
list[Layer2CircuitSideBlockType], Sequence[Layer2CircuitSideBlockType],
AfterValidator(validate_unique_list), AfterValidator(validate_unique_list),
Len(min_length=2, max_length=2), Len(min_length=2, max_length=2),
Doc("A list of two Layer 2 Circuit sides."), Doc("A list of two Layer 2 Circuit sides."),
......
...@@ -52,12 +52,6 @@ def initial_input_generator(product_name: str) -> FormGenerator: ...@@ -52,12 +52,6 @@ def initial_input_generator(product_name: str) -> FormGenerator:
class Layer2CircuitServiceSidesPage(FormPage): class Layer2CircuitServiceSidesPage(FormPage):
model_config = ConfigDict(title=f"{product_name} - Configure Edge Ports") model_config = ConfigDict(title=f"{product_name} - Configure Edge Ports")
vlan_range_label: Label | None = Field(None, exclude=True)
vlan_range_lower_bound: VLAN_ID | None = None
vlan_range_upper_bound: VLAN_ID | None = None
policer_bandwidth: BandwidthString | None = None
if initial_user_input.layer_2_circuit_type == Layer2CircuitType.TAGGED: if initial_user_input.layer_2_circuit_type == Layer2CircuitType.TAGGED:
vlan_range_label: Label = Field("Please set a VLAN range, bounds including.", exclude=True) vlan_range_label: Label = Field("Please set a VLAN range, bounds including.", exclude=True)
vlan_range_lower_bound: VLAN_ID vlan_range_lower_bound: VLAN_ID
...@@ -79,6 +73,22 @@ def initial_input_generator(product_name: str) -> FormGenerator: ...@@ -79,6 +73,22 @@ def initial_input_generator(product_name: str) -> FormGenerator:
side_divider: Divider = Field(None, exclude=True) side_divider: Divider = Field(None, exclude=True)
layer_2_circuit_side_b: Layer2CircuitSideSelection layer_2_circuit_side_b: Layer2CircuitSideSelection
def __init__(self, **data: Any):
"""Initialize fields based on user input conditions."""
super().__init__(**data)
if initial_user_input.layer_2_circuit_type == Layer2CircuitType.TAGGED:
self.vlan_range_label = Field("Please set a VLAN range, bounds including.", exclude=True)
self.vlan_range_lower_bound = VLAN_ID()
self.vlan_range_upper_bound = VLAN_ID()
else:
self.vlan_range_lower_bound = ReadOnlyField(None, default_type=int)
self.vlan_range_upper_bound = ReadOnlyField(None, default_type=int)
if initial_user_input.policer_enabled:
self.policer_bandwidth = BandwidthString()
else:
self.policer_bandwidth = ReadOnlyField(None, default_type=int)
layer_2_circuit_input = yield Layer2CircuitServiceSidesPage layer_2_circuit_input = yield Layer2CircuitServiceSidesPage
return {"product_name": product_name} | initial_user_input.model_dump() | layer_2_circuit_input.model_dump() return {"product_name": product_name} | initial_user_input.model_dump() | layer_2_circuit_input.model_dump()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment