From a60153a28379dfdeb47764bf462353bf420a497e Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Fri, 22 Sep 2023 16:00:10 +0200 Subject: [PATCH] make type ignore statements more specific --- gso/products/product_blocks/iptrunk.py | 2 +- gso/services/provisioning_proxy.py | 9 +++++---- gso/workflows/iptrunk/create_iptrunk.py | 10 +++++----- gso/workflows/iptrunk/migrate_iptrunk.py | 16 +++++++++------- gso/workflows/iptrunk/modify_trunk_interface.py | 2 +- gso/workflows/iptrunk/terminate_iptrunk.py | 2 +- gso/workflows/router/create_router.py | 6 +++--- gso/workflows/router/terminate_router.py | 2 +- gso/workflows/site/create_site.py | 2 +- gso/workflows/tasks/import_iptrunk.py | 6 +++--- gso/workflows/utils.py | 2 +- 11 files changed, 31 insertions(+), 28 deletions(-) diff --git a/gso/products/product_blocks/iptrunk.py b/gso/products/product_blocks/iptrunk.py index e72828ba..89f54e72 100644 --- a/gso/products/product_blocks/iptrunk.py +++ b/gso/products/product_blocks/iptrunk.py @@ -19,7 +19,7 @@ class IptrunkType(strEnum): T = TypeVar("T", covariant=True) -class IptrunkSides(UniqueConstrainedList[T]): # type: ignore +class IptrunkSides(UniqueConstrainedList[T]): # type: ignore[type-var] min_items = 2 max_items = 2 diff --git a/gso/services/provisioning_proxy.py b/gso/services/provisioning_proxy.py index d1358236..c96ef37b 100644 --- a/gso/services/provisioning_proxy.py +++ b/gso/services/provisioning_proxy.py @@ -247,8 +247,8 @@ def _await_pp_results(subscription: SubscriptionModel, label_text: str = DEFAULT class Config: title = f"Deploying {subscription.product.name}..." - warning_label: Label = label_text # type: ignore - pp_run_results: dict = None # type: ignore + warning_label: Label = label_text # type: ignore[assignment] + pp_run_results: dict = None # type: ignore[assignment] confirm: Accept = Accept("INCOMPLETE") @validator("pp_run_results", allow_reuse=True, pre=True, always=True) @@ -299,14 +299,15 @@ def _confirm_pp_results(state: State) -> FormGenerator: if not successful_run: pp_retry_label1: Label = ( - "Provisioning Proxy - playbook execution failed: inspect the output before proceeding" # type: ignore + "Provisioning Proxy - playbook execution failed: " + "inspect the output before proceeding" # type: ignore[assignment] ) run_status: str = ReadOnlyField(state["pp_run_results"]["status"]) run_results: LongText = ReadOnlyField(json.dumps(state["pp_run_results"]["output"], indent=4)) if not successful_run: pp_retry_label: Label = ( - "Click submit to retry. Otherwise, abort the workflow from the process tab." # type: ignore + "Click submit to retry. Otherwise, abort the workflow from the process tab." # type: ignore[assignment] ) yield ConfirmRunPage diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index 4e220311..ae2c8cf9 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -30,7 +30,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: title = product_name tt_number: str - customer: customer_selector() # type: ignore + customer: customer_selector() # type: ignore[valid-type] geant_s_sid: str iptrunk_description: str iptrunk_type: IptrunkType @@ -42,13 +42,13 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: class AeMembersListA(UniqueConstrainedList[str]): min_items = initial_user_input.iptrunk_minimum_links - RouterEnumA = Choice("Select a router", zip(routers.keys(), routers.items())) # type: ignore + RouterEnumA = Choice("Select a router", zip(routers.keys(), routers.items())) # type: ignore[arg-type] class CreateIptrunkSideAForm(FormPage): class Config: title = "Provide subscription details for side A of the trunk." - iptrunk_sideA_node_id: RouterEnumA # type: ignore + iptrunk_sideA_node_id: RouterEnumA # type: ignore[valid-type] iptrunk_sideA_ae_iface: str iptrunk_sideA_ae_geant_a_sid: str iptrunk_sideA_ae_members: AeMembersListA @@ -58,7 +58,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: # Remove the selected router for side A, to prevent any loops routers.pop(str(user_input_side_a.iptrunk_sideA_node_id.name)) - RouterEnumB = Choice("Select a router", zip(routers.keys(), routers.items())) # type: ignore + RouterEnumB = Choice("Select a router", zip(routers.keys(), routers.items())) # type: ignore[arg-type] class AeMembersListB(UniqueConstrainedList[str]): min_items = len(user_input_side_a.iptrunk_sideA_ae_members) @@ -68,7 +68,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: class Config: title = "Provide subscription details for side B of the trunk." - iptrunk_sideB_node_id: RouterEnumB # type: ignore + iptrunk_sideB_node_id: RouterEnumB # type: ignore[valid-type] iptrunk_sideB_ae_iface: str iptrunk_sideB_ae_geant_a_sid: str iptrunk_sideB_ae_members: AeMembersListB diff --git a/gso/workflows/iptrunk/migrate_iptrunk.py b/gso/workflows/iptrunk/migrate_iptrunk.py index 8b9fc6b4..b492606b 100644 --- a/gso/workflows/iptrunk/migrate_iptrunk.py +++ b/gso/workflows/iptrunk/migrate_iptrunk.py @@ -31,7 +31,8 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: } ReplacedSide = Choice( - "Select the side of the IP trunk to be replaced", zip(sides_dict.keys(), sides_dict.items()) # type: ignore + "Select the side of the IP trunk to be replaced", + zip(sides_dict.keys(), sides_dict.items()), # type: ignore[arg-type] ) class OldSideIptrunkForm(FormPage): @@ -44,8 +45,8 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: ) tt_number: str - replace_side: ReplacedSide # type: ignore - warning_label: Label = "Are we moving to a different Site?" # type: ignore + replace_side: ReplacedSide # type: ignore[valid-type] + warning_label: Label = "Are we moving to a different Site?" # type: ignore[assignment] migrate_to_different_site: Optional[bool] = False old_side_input = yield OldSideIptrunkForm @@ -73,7 +74,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: continue routers[str(router_id)] = router_description - NewRouterEnum = Choice("Select a new router", zip(routers.keys(), routers.items())) # type: ignore + NewRouterEnum = Choice("Select a new router", zip(routers.keys(), routers.items())) # type: ignore[arg-type] class LagMemberList(UniqueConstrainedList[str]): min_items = len(subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members) @@ -87,7 +88,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}" ) - new_node: NewRouterEnum # type: ignore + new_node: NewRouterEnum # type: ignore[valid-type] new_lag_interface: str new_lag_member_interfaces: LagMemberList @@ -241,7 +242,8 @@ def confirm_continue_move_fiber() -> FormGenerator: title = "Please confirm before continuing" info_label: Label = ( - "New Trunk interface has been deployed, wait for the physical connection to be moved" # type: ignore + "New Trunk interface has been deployed, " + "wait for the physical connection to be moved." # type: ignore[assignment] ) yield ProvisioningResultPage @@ -303,7 +305,7 @@ def confirm_continue_restore_isis() -> FormGenerator: title = "Please confirm before continuing" info_label: Label = ( - "ISIS config has been deployed, confirm if you want to restore the old metric" # type: ignore + "ISIS config has been deployed, confirm if you want to restore the old metric." # type: ignore[assignment] ) yield ProvisioningResultPage diff --git a/gso/workflows/iptrunk/modify_trunk_interface.py b/gso/workflows/iptrunk/modify_trunk_interface.py index 5e588c0c..87e3b8f5 100644 --- a/gso/workflows/iptrunk/modify_trunk_interface.py +++ b/gso/workflows/iptrunk/modify_trunk_interface.py @@ -23,7 +23,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: geant_s_sid: str = subscription.iptrunk.geant_s_sid iptrunk_description: str = subscription.iptrunk.iptrunk_description iptrunk_type: IptrunkType = subscription.iptrunk.iptrunk_type - iptrunk_speed: PhyPortCapacity = subscription.iptrunk.iptrunk_speed # type: ignore + iptrunk_speed: PhyPortCapacity = subscription.iptrunk.iptrunk_speed # type: ignore[assignment] iptrunk_minimum_links: int = subscription.iptrunk.iptrunk_minimum_links iptrunk_isis_metric: int = ReadOnlyField(subscription.iptrunk.iptrunk_isis_metric) iptrunk_ipv4_network: ipaddress.IPv4Network = ReadOnlyField(subscription.iptrunk.iptrunk_ipv4_network) diff --git a/gso/workflows/iptrunk/terminate_iptrunk.py b/gso/workflows/iptrunk/terminate_iptrunk.py index 8ee23423..b2310d89 100644 --- a/gso/workflows/iptrunk/terminate_iptrunk.py +++ b/gso/workflows/iptrunk/terminate_iptrunk.py @@ -18,7 +18,7 @@ def initial_input_form_generator() -> FormGenerator: class TerminateForm(FormPage): termination_label: Label = ( "Please confirm whether configuration should get removed from the A and B sides of the trunk, and whether " - "IPAM resources should be released." # type: ignore + "IPAM resources should be released." # type: ignore[assignment] ) tt_number: str remove_configuration: bool = True diff --git a/gso/workflows/router/create_router.py b/gso/workflows/router/create_router.py index 7e022acd..be23b415 100644 --- a/gso/workflows/router/create_router.py +++ b/gso/workflows/router/create_router.py @@ -28,7 +28,7 @@ def _site_selector() -> Choice: site_subscriptions[str(site_id)] = site_description # noinspection PyTypeChecker - return Choice("Select a site", zip(site_subscriptions.keys(), site_subscriptions.items())) # type: ignore + return Choice("Select a site", zip(site_subscriptions.keys(), site_subscriptions.items())) # type: ignore[arg-type] def initial_input_form_generator(product_name: str) -> FormGenerator: @@ -37,8 +37,8 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: title = product_name tt_number: str - customer: customer_selector() # type: ignore - router_site: _site_selector() # type: ignore + customer: customer_selector() # type: ignore[valid-type] + router_site: _site_selector() # type: ignore[valid-type] hostname: str ts_port: PortNumber router_vendor: RouterVendor diff --git a/gso/workflows/router/terminate_router.py b/gso/workflows/router/terminate_router.py index 5d4c405e..413e84b9 100644 --- a/gso/workflows/router/terminate_router.py +++ b/gso/workflows/router/terminate_router.py @@ -21,7 +21,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: class TerminateForm(FormPage): termination_label: Label = ( "Please confirm whether configuration should get removed from the router, and whether IPAM resources should" - " be released." # type: ignore + " be released." # type: ignore[assignment] ) tt_number: str remove_configuration: bool = True diff --git a/gso/workflows/site/create_site.py b/gso/workflows/site/create_site.py index e495049e..edcb7a01 100644 --- a/gso/workflows/site/create_site.py +++ b/gso/workflows/site/create_site.py @@ -21,7 +21,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: # noqa: C class Config: title = product_name - customer: customer_selector() # type: ignore + customer: customer_selector() # type: ignore[valid-type] site_name: str site_city: str site_country: str diff --git a/gso/workflows/tasks/import_iptrunk.py b/gso/workflows/tasks/import_iptrunk.py index db4cb347..f1c3e6cf 100644 --- a/gso/workflows/tasks/import_iptrunk.py +++ b/gso/workflows/tasks/import_iptrunk.py @@ -29,7 +29,7 @@ def _generate_routers() -> dict[str, str]: def initial_input_form_generator() -> FormGenerator: routers = _generate_routers() - RouterEnum = Choice("Select a router", zip(routers.keys(), routers.items())) # type: ignore + RouterEnum = Choice("Select a router", zip(routers.keys(), routers.items())) # type: ignore[arg-type] class CreateIptrunkForm(FormPage): class Config: @@ -42,13 +42,13 @@ def initial_input_form_generator() -> FormGenerator: iptrunk_speed: PhyPortCapacity iptrunk_minimum_links: int - iptrunk_sideA_node_id: RouterEnum # type: ignore + iptrunk_sideA_node_id: RouterEnum # type: ignore[valid-type] iptrunk_sideA_ae_iface: str iptrunk_sideA_ae_geant_a_sid: str iptrunk_sideA_ae_members: UniqueConstrainedList[str] iptrunk_sideA_ae_members_descriptions: UniqueConstrainedList[str] - iptrunk_sideB_node_id: RouterEnum # type: ignore + iptrunk_sideB_node_id: RouterEnum # type: ignore[valid-type] iptrunk_sideB_ae_iface: str iptrunk_sideB_ae_geant_a_sid: str iptrunk_sideB_ae_members: UniqueConstrainedList[str] diff --git a/gso/workflows/utils.py b/gso/workflows/utils.py index 453fbea2..02ebed3e 100644 --- a/gso/workflows/utils.py +++ b/gso/workflows/utils.py @@ -11,7 +11,7 @@ def customer_selector() -> Choice: for customer in all_customers(): customers[customer["id"]] = customer["name"] - return Choice("Select a customer", zip(customers.keys(), customers.items())) # type: ignore + return Choice("Select a customer", zip(customers.keys(), customers.items())) # type: ignore[arg-type] def iso_from_ipv4(ipv4_address: IPv4Address) -> str: -- GitLab