Skip to content

Commit 89106a0

Browse files
committed
typing: Have NetDetectionMixin subclass Command
Type checkers do not like the mixin pattern. Fortunately it is not needed here (at least not in its typical form). Having NetDetectionMixin subclass from Command allows us to remove a whole load of type: ignore statements. Change-Id: If6cacf5f4ff05ffedf78469e557e9f635c94df7d Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 8a02564 commit 89106a0

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

openstackclient/network/common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def check_missing_extension_if_error(client_manager, attrs):
5757
raise
5858

5959

60-
class NetDetectionMixin(metaclass=abc.ABCMeta):
60+
class NetDetectionMixin(command.Command, metaclass=abc.ABCMeta):
6161
"""Convenience methods for nova-network vs. neutron decisions.
6262
6363
A live environment detects which network type it is running and creates its
@@ -81,7 +81,7 @@ def _network_type(self):
8181
# Have we set it up yet for this command?
8282
if not hasattr(self, '_net_type'):
8383
try:
84-
if self.app.client_manager.is_network_endpoint_enabled(): # type: ignore
84+
if self.app.client_manager.is_network_endpoint_enabled():
8585
net_type = _NET_TYPE_NEUTRON
8686
else:
8787
net_type = _NET_TYPE_COMPUTE
@@ -135,7 +135,7 @@ def split_help(network_help, compute_help):
135135

136136
def get_parser(self, prog_name: str) -> _argparse.ArgumentParser:
137137
LOG.debug('get_parser(%s)', prog_name)
138-
parser = super().get_parser(prog_name) # type: ignore
138+
parser = super().get_parser(prog_name)
139139
parser = self.update_parser_common(parser)
140140
LOG.debug('common parser: %s', parser)
141141
if self.is_neutron or self.is_docs_build:
@@ -160,12 +160,12 @@ def update_parser_compute(self, parser):
160160
def take_action(self, parsed_args):
161161
if self.is_neutron:
162162
return self.take_action_network(
163-
self.app.client_manager.network, # type: ignore
163+
self.app.client_manager.network,
164164
parsed_args,
165165
)
166166
elif self.is_nova_network:
167167
return self.take_action_compute(
168-
self.app.client_manager.compute, # type: ignore
168+
self.app.client_manager.compute,
169169
parsed_args,
170170
)
171171

0 commit comments

Comments
 (0)