Skip to content

Commit 56a1a56

Browse files
committed
pylint-lint
Avoid using next, input, open, type as function parameter name Refactor a few for loop to use .items() Signed-off-by: Justin Cinkelj <[email protected]>
1 parent 234ebbe commit 56a1a56

19 files changed

+84
-84
lines changed

plugins/module_utils/disk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
class Disk(PayloadMapper):
5454
def __init__(
5555
self,
56-
type,
56+
disk_type,
5757
slot,
5858
uuid=None,
5959
vm_uuid=None,
@@ -67,7 +67,7 @@ def __init__(
6767
):
6868
self.uuid = uuid
6969
self.vm_uuid = vm_uuid
70-
self.type = type
70+
self.type = disk_type
7171
self.cache_mode = cache_mode
7272
self.size = size
7373
self.slot = slot
@@ -118,7 +118,7 @@ def from_hypercore(cls, hypercore_data: dict[Any, Any]) -> Optional[Disk]:
118118
return cls(
119119
uuid=hypercore_data["uuid"],
120120
vm_uuid=hypercore_data["virDomainUUID"],
121-
type=hypercore_data["type"].lower(),
121+
disk_type=hypercore_data["type"].lower(),
122122
cache_mode=hypercore_data["cacheMode"].lower(),
123123
size=hypercore_data["capacity"],
124124
slot=hypercore_data["slot"],
@@ -156,7 +156,7 @@ def from_ansible(cls, ansible_data):
156156
else:
157157
size = None
158158
return cls(
159-
type=disk_type,
159+
disk_type=disk_type,
160160
slot=ansible_data["disk_slot"],
161161
size=size,
162162
cache_mode=ansible_data.get("cache_mode", None),

plugins/module_utils/support_tunnel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323

2424
class SupportTunnel(PayloadMapper):
25-
def __init__(self, open: bool, code: Optional[int]):
26-
self.open = open
25+
def __init__(self, open_flag: bool, code: Optional[int]):
26+
self.open = open_flag
2727
self.code = code
2828

2929
@classmethod
@@ -36,12 +36,12 @@ def from_hypercore(
3636
) -> SupportTunnel:
3737
# There is no None check since get_record is not used (support_tunnel's api behaves different)
3838
if not hypercore_data["tunnelOpen"]:
39-
open = False
39+
open_flag = False
4040
code = None
4141
else:
42-
open = True
42+
open_flag = True
4343
code = hypercore_data["tunnelOpen"]
44-
return cls(open=open, code=code)
44+
return cls(open_flag=open_flag, code=code)
4545

4646
def to_hypercore(self) -> Any:
4747
pass

plugins/module_utils/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ def validate_uuid(value):
4242

4343

4444
def get_query(
45-
input: dict[Any, Any], *field_names: str, ansible_hypercore_map: dict[Any, Any]
45+
query_filter: dict[Any, Any], *field_names: str, ansible_hypercore_map: dict[Any, Any]
4646
):
4747
"""
4848
Wrapps filter_dict and transform_ansible_to_hypercore_query. Prefer to use 'get_query' over filter_dict
4949
even if there's no mapping between hypercore and ansible columns for the sake of verbosity and consistency
5050
"""
51-
ansible_query = filter_dict(input, *field_names)
51+
ansible_query = filter_dict(query_filter, *field_names)
5252
hypercore_query = transform_query(ansible_query, ansible_hypercore_map)
5353
return hypercore_query
5454

5555

56-
def filter_dict(input, *field_names):
56+
def filter_dict(query_filter, *field_names):
5757
output = {}
5858
for field_name in field_names:
59-
if field_name not in input:
59+
if field_name not in query_filter:
6060
continue
61-
value = input[field_name]
61+
value = query_filter[field_name]
6262
if value is not None:
6363
output[field_name] = value
6464
return output

plugins/module_utils/vm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ def from_hypercore_to_ansible(cls, vm_dict: dict) -> str:
176176
# and use machineTypeKeyword if present.
177177
if "machineTypeKeyword" in vm_dict:
178178
_map_hypercore_machine_type_keyword_to_ansible = {
179-
cls._map_ansible_to_hypercore_machine_type_keyword[k]: k
180-
for k in cls._map_ansible_to_hypercore_machine_type_keyword
179+
hypercore_value: ansible_value
180+
for ansible_value, hypercore_value in cls._map_ansible_to_hypercore_machine_type_keyword.items()
181181
}
182182
# "machineTypeKeyword" is available in HyperCore 9.3 or later
183183
return _map_hypercore_machine_type_keyword_to_ansible.get(

plugins/module_utils/vm_snapshot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
device_snapshots: Optional[List[Dict[Any, Any]]] = None,
3939
timestamp: Optional[int] = None,
4040
label: Optional[str] = None,
41-
type: Optional[str] = None,
41+
snapshot_type: Optional[str] = None,
4242
automated_trigger_timestamp: Optional[int] = None,
4343
local_retain_until_timestamp: Optional[float] = None,
4444
remote_retain_until_timestamp: Optional[float] = None,
@@ -53,7 +53,7 @@ def __init__(
5353
self.device_snapshots = device_snapshots if device_snapshots is not None else []
5454
self.timestamp = timestamp
5555
self.label = label
56-
self.type = type
56+
self.type = snapshot_type
5757
self.automated_trigger_timestamp = automated_trigger_timestamp
5858
self.local_retain_until_timestamp = local_retain_until_timestamp
5959
self.remote_retain_until_timestamp = remote_retain_until_timestamp
@@ -134,7 +134,7 @@ def from_hypercore(
134134
],
135135
timestamp=hypercore_data["timestamp"],
136136
label=hypercore_data["label"],
137-
type=hypercore_data["type"],
137+
snapshot_type=hypercore_data["type"],
138138
automated_trigger_timestamp=hypercore_data["automatedTriggerTimestamp"],
139139
local_retain_until_timestamp=hypercore_data["localRetainUntilTimestamp"],
140140
remote_retain_until_timestamp=hypercore_data["remoteRetainUntilTimestamp"],

plugins/modules/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def delete_record(module, rest_client):
251251
return False, dict()
252252

253253

254-
"""
254+
__COMMENT = """
255255
PUT_TIMEOUT_TIME was copied from the iso module for ISO data upload.
256256
Currently, assume we have 4.7 GB ISO and speed 1 MB/s -> 4700 seconds.
257257
Rounded to 3600.

plugins/modules/iso.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
from ..module_utils.rest_client import RestClient
165165
from ..module_utils.task_tag import TaskTag
166166

167-
"""
167+
__COMMENT = """
168168
ISO_TIMEOUT_TIME is timeout for ISO data upload.
169169
Currently, assume we have 4.7 GB ISO and speed 1 MB/s -> 4700 seconds.
170170
Rounded to 3600.

plugins/modules/oidc_config.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ def ensure_present(
128128
)
129129
sleep(1)
130130
continue
131-
else:
132-
raise
131+
raise
133132
# module.warn(f"API during reconfiguration ii={ii}")
134133

135134
for ii in range(max_retries):
@@ -143,8 +142,7 @@ def ensure_present(
143142
)
144143
sleep(1)
145144
continue
146-
else:
147-
raise
145+
raise
148146
# module.warn(f"API after reconfiguration ii={ii}")
149147

150148
after = updated_oidc.to_ansible() if updated_oidc else None

plugins/modules/version_update_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ def main() -> None:
199199
try:
200200
client = Client.get_client(module.params["cluster_instance"])
201201
rest_client = RestClient(client)
202-
records, next, latest = run(rest_client)
203-
module.exit_json(changed=False, records=records, next=next, latest=latest)
202+
records, next_version, latest_version = run(rest_client)
203+
module.exit_json(changed=False, records=records, next=next_version, latest=latest_version)
204204

205205
except errors.ScaleComputingError as e:
206206
module.fail_json(msg=str(e))

tests/unit/plugins/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ def fail_json_mock(self, **result):
9090
raise AnsibleRunEnd(False, result)
9191

9292

93-
def run_mock(module, client, another_client=None):
93+
def run_mock(module, _client, _another_client=None):
9494
return False, {}, dict(before={}, after={})
9595

9696

97-
def run_mock_with_reboot(module, client, another_client=None):
97+
def run_mock_with_reboot(module, _client, _another_client=None):
9898
return False, {}, dict(before={}, after={}), False
9999

100100

101101
# for syslog_server module
102-
def run_mock_with_record_and_records(module, client, another_client=None):
102+
def run_mock_with_record_and_records(module, _client, _another_client=None):
103103
return False, {}, [], dict(before={}, after={})
104104

105105

106-
def run_mock_info(module, client, another_client=None):
106+
def run_mock_info(module, _client, _another_client=None):
107107
return False, []
108108

109109

0 commit comments

Comments
 (0)