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 14, 2023
1 parent 0d050bd commit c8afc34
Show file tree
Hide file tree
Showing 303 changed files with 3,151 additions and 3,238 deletions.
8 changes: 4 additions & 4 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 @@ -38,8 +38,8 @@ 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}
keyspaces=[*system_keyspaces, "keyspace1"],
replication_factors={dc: len(status[dc].keys()) for dc in status},
)

self.log.info("Running rebuild on each node in new DC")
Expand Down Expand Up @@ -90,7 +90,7 @@ def add_node_in_new_dc(self) -> BaseNode:
self.monitors.reconfigure_scylla_monitoring()

status = self.db_cluster.get_nodetool_status()
assert len(status.keys()) == 2, f"new datacenter was not registered. Cluster status: {status}" # noqa: PLR2004
assert len(status.keys()) == 2, f"new datacenter was not registered. Cluster status: {status}"
self.log.info("New DC to cluster has been added")
return new_node

Expand Down
16 changes: 8 additions & 8 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 @@ -175,7 +175,7 @@ def verify_users(self):
out = self.node.remoter.run(cmd="ls -ltr --full-time /home", verbose=True).stdout.strip()
for line in out.splitlines():
splitted_line = line.split()
if len(splitted_line) <= 2: # noqa: PLR2004
if len(splitted_line) <= 2:
continue
user = splitted_line[-1]
if user == "centos":
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
6 changes: 2 additions & 4 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 Expand Up @@ -66,8 +64,8 @@ def test_change_seed_address_to_hostname(self):
addresses = {}
seeds = []
for node in self.db_cluster.nodes:
if hasattr(node._instance, 'public_dns_name'):
addresses[node.private_ip_address] = node._instance.public_dns_name
if hasattr(node._instance, 'public_dns_name'): # noqa: SLF001
addresses[node.private_ip_address] = node._instance.public_dns_name # noqa: SLF001
if node.is_seed:
seeds.append(node.private_ip_address)
else:
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
2 changes: 1 addition & 1 deletion docker/alternator-dns/dns_server.py
100644 → 100755
Original file line number Diff line number Diff line change
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
2 changes: 0 additions & 2 deletions functional_tests/__init__.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 functional_tests/scylla_operator/__init__.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
26 changes: 12 additions & 14 deletions functional_tests/scylla_operator/conftest.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 @@ -43,17 +41,17 @@


@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()
if rep.skipped:
item._test_result = ('SKIPPED', rep.longrepr[2])
TESTER.update_test_status(item.nodeid, *item._test_result)
item._test_result = ('SKIPPED', rep.longrepr[2]) # noqa: SLF001
TESTER.update_test_status(item.nodeid, *item._test_result) # noqa: SLF001
elif rep.passed:
item._test_result = ('SUCCESS', None)
item._test_result = ('SUCCESS', None) # noqa: SLF001
elif not rep.passed:
item._test_result = ('FAILED', str(rep.longrepr))
item._test_result = ('FAILED', str(rep.longrepr)) # noqa: SLF001


@pytest.fixture(autouse=True, name="harvest_test_results")
Expand All @@ -63,7 +61,7 @@ def fixture_harvest_test_results(request, tester: ScyllaOperatorFunctionalCluste
def publish_test_result():
tester.update_test_status(
request.node.nodeid,
*request.node._test_result)
*request.node._test_result) # noqa: SLF001

request.addfinalizer(publish_test_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 All @@ -225,10 +223,10 @@ def skip_if_not_supported_scylla_version(request: pytest.FixtureRequest,
def skip_based_on_operator_version(request: pytest.FixtureRequest, tester: ScyllaOperatorFunctionalClusterTester):

if required_operator := request.node.get_closest_marker('required_operator'):
if (version.LegacyVersion(tester.k8s_cluster._scylla_operator_chart_version.split("-")[0])
if (version.LegacyVersion(tester.k8s_cluster._scylla_operator_chart_version.split("-")[0]) # noqa: SLF001
< version.LegacyVersion(required_operator.args[0])):
pytest.skip(f"require operator version: {required_operator.args[0]} , "
f"current version: {tester.k8s_cluster._scylla_operator_chart_version}")
f"current version: {tester.k8s_cluster._scylla_operator_chart_version}") # noqa: SLF001


@pytest.fixture(autouse=True)
Expand Down
2 changes: 0 additions & 2 deletions functional_tests/scylla_operator/libs/__init__.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 functional_tests/scylla_operator/libs/auxiliary.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 @@ -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 All @@ -42,7 +40,7 @@ def update_test_status(self, test_name, status, error=None):

def get_test_failures(self):
for test_name, test_data in self.test_data.items():
status, message = (test_data[0], test_data[1]) if len(test_data) == 2 else ('UNKNOWN', '') # noqa: PLR2004
status, message = (test_data[0], test_data[1]) if len(test_data) == 2 else ('UNKNOWN', '')
if status != 'SUCCESS':
TestFrameworkEvent(
source=self.__class__.__name__,
Expand Down
6 changes: 2 additions & 4 deletions functional_tests/scylla_operator/libs/helpers.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 @@ -158,7 +156,7 @@ def reinstall_scylla_manager(db_cluster: ScyllaPodCluster, manager_version: str)
log.debug(db_cluster.k8s_cluster.helm_install(
target_chart_name="scylla-manager",
source_chart_name="scylla-operator/scylla-manager",
version=db_cluster.k8s_cluster._scylla_operator_chart_version,
version=db_cluster.k8s_cluster._scylla_operator_chart_version, # noqa: SLF001
use_devel=True,
values=values,
namespace=SCYLLA_MANAGER_NAMESPACE,
Expand Down Expand Up @@ -216,7 +214,7 @@ def verify_resharding_on_k8s(db_cluster: ScyllaPodCluster, cpus: Union[str, int,
# Calculate the time spent for resharding. We need to have it be bigger than 2minutes
# because it is the timeout of the liveness probe for Scylla pods.
resharding_time = time.time() - resharding_started
if resharding_time < 120: # noqa: PLR2004
if resharding_time < 120:
log.warning(
"Resharding was too fast - '%s's (<120s) on the '%s' node",
resharding_time, node.name)
Expand Down
Loading

0 comments on commit c8afc34

Please sign in to comment.