Skip to content

Commit ac69c40

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 d40f1e2 commit ac69c40

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
@@ -49,7 +49,7 @@
4949
class Disk(PayloadMapper):
5050
def __init__(
5151
self,
52-
type,
52+
disk_type,
5353
slot,
5454
uuid=None,
5555
vm_uuid=None,
@@ -63,7 +63,7 @@ def __init__(
6363
):
6464
self.uuid = uuid
6565
self.vm_uuid = vm_uuid
66-
self.type = type
66+
self.type = disk_type
6767
self.cache_mode = cache_mode
6868
self.size = size
6969
self.slot = slot
@@ -114,7 +114,7 @@ def from_hypercore(cls, hypercore_data: dict[Any, Any]) -> Optional[Disk]:
114114
return cls(
115115
uuid=hypercore_data["uuid"],
116116
vm_uuid=hypercore_data["virDomainUUID"],
117-
type=hypercore_data["type"].lower(),
117+
disk_type=hypercore_data["type"].lower(),
118118
cache_mode=hypercore_data["cacheMode"].lower(),
119119
size=hypercore_data["capacity"],
120120
slot=hypercore_data["slot"],
@@ -152,7 +152,7 @@ def from_ansible(cls, ansible_data):
152152
else:
153153
size = None
154154
return cls(
155-
type=disk_type,
155+
disk_type=disk_type,
156156
slot=ansible_data["disk_slot"],
157157
size=size,
158158
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
@@ -17,8 +17,8 @@
1717

1818

1919
class SupportTunnel(PayloadMapper):
20-
def __init__(self, open: bool, code: Optional[int]):
21-
self.open = open
20+
def __init__(self, open_flag: bool, code: Optional[int]):
21+
self.open = open_flag
2222
self.code = code
2323

2424
@classmethod
@@ -31,12 +31,12 @@ def from_hypercore(
3131
) -> SupportTunnel:
3232
# There is no None check since get_record is not used (support_tunnel's api behaves different)
3333
if not hypercore_data["tunnelOpen"]:
34-
open = False
34+
open_flag = False
3535
code = None
3636
else:
37-
open = True
37+
open_flag = True
3838
code = hypercore_data["tunnelOpen"]
39-
return cls(open=open, code=code)
39+
return cls(open_flag=open_flag, code=code)
4040

4141
def to_hypercore(self) -> Any:
4242
pass

plugins/module_utils/utils.py

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

3939

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

5151

52-
def filter_dict(input, *field_names):
52+
def filter_dict(query_filter, *field_names):
5353
output = {}
5454
for field_name in field_names:
55-
if field_name not in input:
55+
if field_name not in query_filter:
5656
continue
57-
value = input[field_name]
57+
value = query_filter[field_name]
5858
if value is not None:
5959
output[field_name] = value
6060
return output

plugins/module_utils/vm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ def from_hypercore_to_ansible(cls, vm_dict: dict) -> str:
164164
# and use machineTypeKeyword if present.
165165
if "machineTypeKeyword" in vm_dict:
166166
_map_hypercore_machine_type_keyword_to_ansible = {
167-
cls._map_ansible_to_hypercore_machine_type_keyword[k]: k
168-
for k in cls._map_ansible_to_hypercore_machine_type_keyword
167+
hypercore_value: ansible_value
168+
for ansible_value, hypercore_value in cls._map_ansible_to_hypercore_machine_type_keyword.items()
169169
}
170170
# "machineTypeKeyword" is available in HyperCore 9.3 or later
171171
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
@@ -32,7 +32,7 @@ def __init__(
3232
device_snapshots: Optional[List[Dict[Any, Any]]] = None,
3333
timestamp: Optional[int] = None,
3434
label: Optional[str] = None,
35-
type: Optional[str] = None,
35+
snapshot_type: Optional[str] = None,
3636
automated_trigger_timestamp: Optional[int] = None,
3737
local_retain_until_timestamp: Optional[float] = None,
3838
remote_retain_until_timestamp: Optional[float] = None,
@@ -47,7 +47,7 @@ def __init__(
4747
self.device_snapshots = device_snapshots if device_snapshots is not None else []
4848
self.timestamp = timestamp
4949
self.label = label
50-
self.type = type
50+
self.type = snapshot_type
5151
self.automated_trigger_timestamp = automated_trigger_timestamp
5252
self.local_retain_until_timestamp = local_retain_until_timestamp
5353
self.remote_retain_until_timestamp = remote_retain_until_timestamp
@@ -128,7 +128,7 @@ def from_hypercore(
128128
],
129129
timestamp=hypercore_data["timestamp"],
130130
label=hypercore_data["label"],
131-
type=hypercore_data["type"],
131+
snapshot_type=hypercore_data["type"],
132132
automated_trigger_timestamp=hypercore_data["automatedTriggerTimestamp"],
133133
local_retain_until_timestamp=hypercore_data["localRetainUntilTimestamp"],
134134
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
@@ -248,7 +248,7 @@ def delete_record(module, rest_client):
248248
return False, dict()
249249

250250

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

plugins/modules/iso.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
from ..module_utils.rest_client import RestClient
162162
from ..module_utils.task_tag import TaskTag
163163

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

plugins/modules/oidc_config.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ def ensure_present(
123123
)
124124
sleep(1)
125125
continue
126-
else:
127-
raise
126+
raise
128127
# module.warn(f"API during reconfiguration ii={ii}")
129128

130129
for ii in range(max_retries):
@@ -138,8 +137,7 @@ def ensure_present(
138137
)
139138
sleep(1)
140139
continue
141-
else:
142-
raise
140+
raise
143141
# module.warn(f"API after reconfiguration ii={ii}")
144142

145143
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
@@ -194,8 +194,8 @@ def main() -> None:
194194
try:
195195
client = Client.get_client(module.params["cluster_instance"])
196196
rest_client = RestClient(client)
197-
records, next, latest = run(rest_client)
198-
module.exit_json(changed=False, records=records, next=next, latest=latest)
197+
records, next_version, latest_version = run(rest_client)
198+
module.exit_json(changed=False, records=records, next=next_version, latest=latest_version)
199199

200200
except errors.ScaleComputingError as e:
201201
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
@@ -93,20 +93,20 @@ def fail_json_mock(self, **result):
9393
raise AnsibleRunEnd(False, result)
9494

9595

96-
def run_mock(module, client, another_client=None):
96+
def run_mock(module, _client, _another_client=None):
9797
return False, {}, dict(before={}, after={})
9898

9999

100-
def run_mock_with_reboot(module, client, another_client=None):
100+
def run_mock_with_reboot(module, _client, _another_client=None):
101101
return False, {}, dict(before={}, after={}), False
102102

103103

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

108108

109-
def run_mock_info(module, client, another_client=None):
109+
def run_mock_info(module, _client, _another_client=None):
110110
return False, []
111111

112112

0 commit comments

Comments
 (0)