Skip to content

Commit 23a9d0c

Browse files
committed
typing: Remove unnecessary type: ignore statements
Many of these are trivially resolvable. Change-Id: I0a8463a7ff9b0eff06426270987fdf862461d66a Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 89106a0 commit 23a9d0c

6 files changed

Lines changed: 20 additions & 12 deletions

File tree

openstackclient/common/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def take_action(self, parsed_args):
6161
# TODO(bapalm): Fix this when cliff properly supports
6262
# handling the detection rather than using the hard-code below.
6363
if parsed_args.formatter == 'table':
64-
command_names = utils.format_list(command_names, "\n") # type: ignore
64+
command_names = utils.format_list(command_names, "\n") # type: ignore[assignment]
6565

6666
commands.append((group, command_names))
6767

openstackclient/compute/v2/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,7 @@ def _match_image(image_api, wanted_properties):
19091909

19101910
networks = parsed_args.nics[0]
19111911
else:
1912+
_networks = []
19121913
for nic in parsed_args.nics:
19131914
if 'tag' in nic:
19141915
if not sdk_utils.supports_microversion(
@@ -1969,7 +1970,8 @@ def _match_image(image_api, wanted_properties):
19691970
if nic.get('tag'): # tags are optional
19701971
network['tag'] = nic['tag']
19711972

1972-
networks.append(network) # type: ignore[union-attr]
1973+
_networks.append(network)
1974+
networks = _networks
19731975

19741976
if not parsed_args.nics and sdk_utils.supports_microversion(
19751977
compute_client, '2.37'

openstackclient/image/v1/image.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@ def take_action(self, parsed_args):
314314
else:
315315
# Read file from stdin
316316
if not sys.stdin.isatty():
317-
if os.name == "nt":
317+
if sys.platform == "win32":
318318
import msvcrt
319319

320-
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) # type: ignore
320+
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
321321
if hasattr(sys.stdin, 'buffer'):
322322
kwargs['data'] = sys.stdin.buffer
323323
else:
@@ -785,10 +785,10 @@ def take_action(self, parsed_args):
785785
# Read file from stdin
786786
if sys.stdin.isatty() is not True:
787787
if parsed_args.stdin:
788-
if os.name == "nt":
788+
if sys.platform == "win32":
789789
import msvcrt
790790

791-
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) # type: ignore
791+
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
792792
if hasattr(sys.stdin, 'buffer'):
793793
kwargs['data'] = sys.stdin.buffer
794794
else:

openstackclient/image/v2/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ def get_data_from_stdin():
166166
image = sys.stdin
167167
if hasattr(sys.stdin, 'buffer'):
168168
image = sys.stdin.buffer
169-
if os.name == "nt":
169+
if sys.platform == "win32":
170170
import msvcrt
171171

172-
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) # type: ignore
172+
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
173173

174174
return image
175175
else:

openstackclient/volume/v2/volume_type.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Volume v2 Type action implementations"""
1616

17+
from collections.abc import MutableMapping
1718
import functools
1819
import logging
1920
from typing import Any
@@ -439,7 +440,9 @@ def take_action(self, parsed_args):
439440
is_public=parsed_args.is_public,
440441
)
441442

442-
formatters = {'Extra Specs': format_columns.DictColumn}
443+
formatters: MutableMapping[str, Any] = {
444+
'Extra Specs': format_columns.DictColumn
445+
}
443446

444447
if parsed_args.encryption_type:
445448
encryption = {}
@@ -466,7 +469,7 @@ def take_action(self, parsed_args):
466469
_EncryptionInfoColumn = functools.partial(
467470
EncryptionInfoColumn, encryption_data=encryption
468471
)
469-
formatters['id'] = _EncryptionInfoColumn # type: ignore
472+
formatters['id'] = _EncryptionInfoColumn
470473

471474
return (
472475
column_headers,

openstackclient/volume/v3/volume_type.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
"""Volume v3 Type action implementations"""
1515

16+
from collections.abc import MutableMapping
1617
import functools
1718
import logging
1819
from typing import Any
@@ -522,7 +523,9 @@ def take_action(self, parsed_args):
522523
is_public=parsed_args.is_public,
523524
)
524525

525-
formatters = {'Extra Specs': format_columns.DictColumn}
526+
formatters: MutableMapping[str, Any] = {
527+
'Extra Specs': format_columns.DictColumn
528+
}
526529

527530
if parsed_args.encryption_type:
528531
encryption = {}
@@ -549,7 +552,7 @@ def take_action(self, parsed_args):
549552
_EncryptionInfoColumn = functools.partial(
550553
EncryptionInfoColumn, encryption_data=encryption
551554
)
552-
formatters['id'] = _EncryptionInfoColumn # type: ignore
555+
formatters['id'] = _EncryptionInfoColumn
553556

554557
return (
555558
column_headers,

0 commit comments

Comments
 (0)