Skip to content

Commit

Permalink
feature(ruff): enable more checkers
Browse files Browse the repository at this point in the history
Enable a much bigger list of checkers, that would be equivelent
to the checkers we had in pyint
  • Loading branch information
fruch committed Feb 12, 2023
1 parent bd4e87c commit f8145d3
Show file tree
Hide file tree
Showing 399 changed files with 3,231 additions and 3,312 deletions.
4 changes: 2 additions & 2 deletions add_new_dc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_add_new_dc(self) -> None:
status = self.db_cluster.get_nodetool_status()
self.reconfigure_keyspaces_to_use_network_topology_strategy(
keyspaces=system_keyspaces,
replication_factors={dc: len(status[dc].keys()) for dc in status}
replication_factors={dc: len(status[dc].keys()) for dc in status},
)
self.prewrite_db_with_data()
read_thread, write_thread = self.start_stress_during_adding_new_dc()
Expand All @@ -39,7 +39,7 @@ def test_add_new_dc(self) -> None:
status = self.db_cluster.get_nodetool_status()
self.reconfigure_keyspaces_to_use_network_topology_strategy(
keyspaces=system_keyspaces + ["keyspace1"],
replication_factors={dc: len(status[dc].keys()) for dc in status}
replication_factors={dc: len(status[dc].keys()) for dc in status},
)

self.log.info("Running rebuild on each node in new DC")
Expand Down
14 changes: 7 additions & 7 deletions artifacts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"aws": ["Ec2Snitch", "Ec2MultiRegionSnitch"],
"gce": ["GoogleCloudSnitch"],
"azure": ["AzureSnitch"],
"docker": ["GossipingPropertyFileSnitch", "SimpleSnitch"]
"docker": ["GossipingPropertyFileSnitch", "SimpleSnitch"],
}


Expand Down Expand Up @@ -215,13 +215,13 @@ def verify_snitch(self, backend_name: str):
with self.subTest('verify snitch against describecluster output'):
self.assertTrue(any(snitch_matches_describecluster),
msg=f"Expected snitch matches for describecluster to not be empty, but was. Snitch "
f"matches: {snitch_matches_describecluster}"
f"matches: {snitch_matches_describecluster}",
)

with self.subTest('verify snitch against scylla.yaml configuration'):
self.assertTrue(any(snitch_matches_scylla_yaml),
msg=f"Expected snitch matches for scylla yaml to not be empty, but was. Snitch "
f"matches: {snitch_matches_scylla_yaml}"
f"matches: {snitch_matches_scylla_yaml}",
)

def verify_write_back_cache_param(self) -> None:
Expand All @@ -241,8 +241,8 @@ def verify_docker_latest_match_release(self) -> None:
self.log.debug('latest info: %s', pprint.pformat(docker_latest))
self.log.debug('%s info: %s ', latest_version, pprint.pformat(docker_release))

latest_digests = set(image['digest'] for image in docker_latest['images'])
release_digests = set(image['digest'] for image in docker_release['images'])
latest_digests = {image['digest'] for image in docker_latest['images']}
release_digests = {image['digest'] for image in docker_release['images']}

assert latest_digests == release_digests, \
f"latest != {latest_version}, images digest differs [{latest_digests}] != [{release_digests}]"
Expand Down Expand Up @@ -412,7 +412,7 @@ def get_email_data(self):
email_data = self._get_common_email_data()
try:
node = self.node
except Exception:
except Exception: # noqa: BLE001
node = None
if node:
scylla_packages = node.scylla_packages_installed
Expand All @@ -424,6 +424,6 @@ def get_email_data(self):
"scylla_packages_installed": scylla_packages,
"unified_package": self.params.get("unified_package"),
"nonroot_offline_install": self.params.get("nonroot_offline_install"),
"scylla_repo": self.params.get("scylla_repo"), })
"scylla_repo": self.params.get("scylla_repo")})

return email_data
2 changes: 0 additions & 2 deletions big_cluster_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
6 changes: 2 additions & 4 deletions cdc_replication_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down Expand Up @@ -41,7 +39,7 @@ def mode_str(mode: Mode) -> str:
return {
Mode.DELTA: 'delta',
Mode.PREIMAGE: 'preimage',
Mode.POSTIMAGE: 'postimage'
Mode.POSTIMAGE: 'postimage',
}[mode]


Expand Down Expand Up @@ -426,7 +424,7 @@ def get_email_data(self) -> dict:
"oracle_db_version":
self.cs_db_cluster.nodes[0].scylla_version if self.cs_db_cluster else "N/A",
"oracle_instance_type": self.params.get("instance_type_db_oracle"),
"consistency_status": self.consistency_ok
"consistency_status": self.consistency_ok,
})

return email_data
2 changes: 0 additions & 2 deletions cluster_configuration_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
2 changes: 0 additions & 2 deletions corrupt_then_rebuild_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
2 changes: 0 additions & 2 deletions cql_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
2 changes: 0 additions & 2 deletions custom_cs_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
2 changes: 0 additions & 2 deletions destroy_data_then_repair_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
4 changes: 2 additions & 2 deletions docker/alternator-dns/dns_server.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/python3 # noqa: INP001
import sys
import dnslib.server
import dnslib
Expand Down Expand Up @@ -34,7 +34,7 @@ def livenodes_update():
# If we're successful, replace livenodes by the new list
livenodes = a
print(livenodes)
except Exception:
except Exception: # noqa: BLE001
# TODO: contacting this ip was unsuccessful, maybe we should
# remove it from the list of live nodes.
pass
Expand Down
2 changes: 0 additions & 2 deletions enospc_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
4 changes: 1 addition & 3 deletions functional_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down
2 changes: 1 addition & 1 deletion functional_tests/mocked/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down
2 changes: 1 addition & 1 deletion functional_tests/mocked/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down
2 changes: 1 addition & 1 deletion functional_tests/mocked/test_aws_region.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down
4 changes: 1 addition & 3 deletions functional_tests/scylla_operator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down
14 changes: 6 additions & 8 deletions functional_tests/scylla_operator/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down Expand Up @@ -43,7 +41,7 @@


@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
def pytest_runtest_makereport(item, call): # noqa: ARG001
# Populate test result to test function instance
outcome = yield
rep = outcome.get_result()
Expand Down Expand Up @@ -116,14 +114,14 @@ def fixture_db_cluster(tester: ScyllaOperatorFunctionalClusterTester):
_bring_cluster_back_to_original_state(
tester,
config_map=original_scylla_config_map,
original_scylla_cluster_spec=original_scylla_cluster_spec
original_scylla_cluster_spec=original_scylla_cluster_spec,
)


def _bring_cluster_back_to_original_state(
tester: ScyllaOperatorFunctionalClusterTester,
config_map: dict,
original_scylla_cluster_spec: dict
original_scylla_cluster_spec: dict,
):
restart = False
db_cluster = tester.db_cluster
Expand Down Expand Up @@ -174,7 +172,7 @@ def _bring_cluster_back_to_original_state(
db_cluster.restart_scylla()
db_cluster.wait_for_nodes_up_and_normal(
nodes=db_cluster.nodes, verification_node=db_cluster.nodes[0])
except Exception as exc:
except Exception as exc: # noqa: BLE001
tester.healthy_flag = False
pytest.fail("Failed to bring cluster nodes back to original state due to :\n" +
"".join(traceback.format_exception(type(exc), exc, exc.__traceback__)))
Expand Down Expand Up @@ -216,7 +214,7 @@ def skip_if_not_supported_scylla_version(request: pytest.FixtureRequest,
return
requires_scylla_versions = requires_scylla_versions.args
try:
version_utils.scylla_versions(*requires_scylla_versions)(lambda c: None)(tester.db_cluster)
version_utils.scylla_versions(*requires_scylla_versions)(lambda c: None)(tester.db_cluster) # noqa: ARG005
except version_utils.MethodVersionNotFound as exc:
pytest.skip(str(exc))

Expand Down
4 changes: 1 addition & 3 deletions functional_tests/scylla_operator/libs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down
6 changes: 2 additions & 4 deletions functional_tests/scylla_operator/libs/auxiliary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down Expand Up @@ -33,7 +31,7 @@ def get_email_data(self):
email_data = self._get_common_email_data()
email_data.update({
"test_statuses": self.test_data,
"scylla_ami_id": self.params.get("ami_id_db_scylla") or "-", }
"scylla_ami_id": self.params.get("ami_id_db_scylla") or "-"},
)
return email_data

Expand Down
4 changes: 1 addition & 3 deletions functional_tests/scylla_operator/libs/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down
14 changes: 6 additions & 8 deletions functional_tests/scylla_operator/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify # noqa: INP001
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
Expand Down Expand Up @@ -33,7 +31,7 @@
ScyllaPodCluster,
SCYLLA_NAMESPACE,
SCYLLA_MANAGER_NAMESPACE,
SCYLLA_OPERATOR_NAMESPACE
SCYLLA_OPERATOR_NAMESPACE,
)
from sdcm.mgmt import TaskStatus
from sdcm.utils.k8s import (
Expand Down Expand Up @@ -203,7 +201,7 @@ def test_mgmt_backup(db_cluster, manager_version):
mgr_cluster = db_cluster.get_cluster_manager()
backup_bucket_location = db_cluster.params.get('backup_bucket_location')
bucket_name = f"s3:{backup_bucket_location.split()[0]}"
mgr_task = mgr_cluster.create_backup_task(location_list=[bucket_name, ])
mgr_task = mgr_cluster.create_backup_task(location_list=[bucket_name])
assert mgr_task, "Failed to create backup task"
status = mgr_task.wait_and_get_final_status(timeout=7200, step=5, only_final=True)
assert TaskStatus.DONE == status
Expand Down Expand Up @@ -292,7 +290,7 @@ def test_check_operator_operability_when_scylla_crd_is_incorrect(db_cluster):
'serviceAccount': {
'create': True,
'annotations': {},
'name': f"{cluster_name}-member"
'name': f"{cluster_name}-member",
},
'developerMode': True,
'sysctls': ["fs.aio-max-nr=1048576"],
Expand All @@ -306,7 +304,7 @@ def test_check_operator_operability_when_scylla_crd_is_incorrect(db_cluster):
'limits': {'cpu': 1, 'memory': "200Mi"},
'requests': {'cpu': 1, 'memory': "200Mi"},
},
}]
}],
})
db_cluster.k8s_cluster.kubectl(f"create namespace {namespace}", ignore_status=True)
db_cluster.k8s_cluster.helm_install(
Expand Down Expand Up @@ -396,7 +394,7 @@ def change_cluster_spec() -> None:
# NOTE: increase the value only when the sysctl spec update is successful
# to avoid false negative results in further assertions
expected_aio_max_nr_value += 1
except Exception as error:
except Exception as error: # noqa: BLE001
str_error = str(error)
log.debug("Change /spec/sysctls value to %d failed. Error: %s",
expected_aio_max_nr_value, str_error)
Expand Down
4 changes: 1 addition & 3 deletions gemini_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down Expand Up @@ -28,7 +26,7 @@ class GeminiTest(ClusterTester):
"cmd": ["N/A"],
"status": "Not Running",
"results": [],
'errors': {}
'errors': {},
}

def test_random_load(self):
Expand Down
2 changes: 0 additions & 2 deletions grow_cluster_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
2 changes: 1 addition & 1 deletion jepsen_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_jepsen(self):
creds = f"--username {self.db_cluster.nodes[0].ssh_login_info['user']} --ssh-private-key ~/{DB_SSH_KEY}"
run_jepsen_cmd = partial(
getattr(self, f"run_jepsen_cmd_{self.params.get('jepsen_test_run_policy')}"),
ntimes=self.params.get("jepsen_test_count")
ntimes=self.params.get("jepsen_test_count"),
)
passed = True
for test in self.params.get("jepsen_test_cmd"):
Expand Down
2 changes: 1 addition & 1 deletion longevity_lwt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run_prepare_write_cmd(self):
if self.db_cluster.nemesis_count > 1:
self.data_validator = MagicMock()
DataValidatorEvent.DataValidator(severity=Severity.WARNING,
message="Test runs with parallel nemesis. Data validator is disabled."
message="Test runs with parallel nemesis. Data validator is disabled.",
).publish()
else:
self.data_validator = LongevityDataValidator(longevity_self_object=self,
Expand Down
4 changes: 1 addition & 3 deletions longevity_operator_multi_tenant_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down Expand Up @@ -32,6 +30,6 @@ def _run_test_on_one_tenant(tenant):
object_set = ParallelObject(
timeout=int(self.test_duration) * 60,
objects=[[tenant] for tenant in self.tenants],
num_workers=self.k8s_cluster.tenants_number
num_workers=self.k8s_cluster.tenants_number,
)
object_set.run(func=_run_test_on_one_tenant, unpack_objects=True, ignore_exceptions=False)
2 changes: 0 additions & 2 deletions longevity_sla_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
Expand Down
Loading

0 comments on commit f8145d3

Please sign in to comment.