Skip to content

Commit

Permalink
remove '!r' in format output
Browse files Browse the repository at this point in the history
  • Loading branch information
elfkuzco committed Jun 21, 2024
1 parent f195d64 commit 9a8cea8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions backend/src/mirrors_qa_backend/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def initialize_mirrors() -> None:
if nb_mirrors == 0:
logger.info("No mirrors exist in database.")
if not current_mirrors:
logger.info(f"No mirrors were found on {Settings.MIRRORS_URL!r}")
logger.info(f"No mirrors were found on {Settings.MIRRORS_URL}")
return
result = create_or_update_mirror_status(session, current_mirrors)
logger.info(
f"Registered {result.nb_mirrors_added} mirrors "
f"from {Settings.MIRRORS_URL!r}"
f"from {Settings.MIRRORS_URL}"
)
else:
logger.info(f"Found {nb_mirrors} mirrors in database.")
Expand Down
10 changes: 5 additions & 5 deletions backend/src/mirrors_qa_backend/db/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def create_mirrors(session: OrmSession, mirrors: list[schemas.Mirror]) -> int:
db_mirror.country = country
session.add(db_mirror)
logger.debug(
f"Registered new mirror: {db_mirror.id!r} for country: {country.name!r}"
f"Registered new mirror: {db_mirror.id} for country: {country.name}"
)
nb_created += 1
return nb_created
Expand Down Expand Up @@ -96,16 +96,16 @@ def create_or_update_mirror_status(
for db_mirror_id, db_mirror in db_mirrors.items():
if db_mirror_id not in current_mirrors:
logger.debug(
f"Disabling mirror: {db_mirror.id!r} for "
f"country: {db_mirror.country.name!r}"
f"Disabling mirror: {db_mirror.id} for "
f"country: {db_mirror.country.name}"
)
db_mirror.enabled = False
session.add(db_mirror)
result.nb_mirrors_disabled += 1
elif not db_mirror.enabled: # re-enable mirror if it was disabled
logger.debug(
f"Re-enabling mirror: {db_mirror.id!r} for "
f"country: {db_mirror.country.name!r}"
f"Re-enabling mirror: {db_mirror.id} for "
f"country: {db_mirror.country.name}"
)
db_mirror.enabled = True
session.add(db_mirror)
Expand Down
4 changes: 1 addition & 3 deletions backend/src/mirrors_qa_backend/db/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def create_worker(
) -> Worker:
"""Creates a worker using RSA private key."""
if get_worker(session, worker_id) is not None:
raise DuplicatePrimaryKeyError(
f"A worker with id {worker_id!r} already exists."
)
raise DuplicatePrimaryKeyError(f"A worker with id {worker_id} already exists.")
try:
private_key = load_private_key_from_path(private_key_fpath)
except Exception as exc:
Expand Down
4 changes: 2 additions & 2 deletions backend/src/mirrors_qa_backend/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def is_country_row(tag: Tag) -> bool:

if body is None or isinstance(body, NavigableString | int):
raise MirrorsExtractError(
f"unable to parse mirrors information from {Settings.MIRRORS_URL!r}"
f"unable to parse mirrors information from {Settings.MIRRORS_URL}"
)

mirrors: list[schemas.Mirror] = []
Expand All @@ -58,7 +58,7 @@ def is_country_row(tag: Tag) -> bool:
try:
country: Any = pycountry.countries.search_fuzzy(country_name)[0]
except LookupError:
logger.error(f"Could not get information for country: {country_name!r}")
logger.error(f"Could not get information for country: {country_name}")
continue
else:
mirrors.append(
Expand Down
6 changes: 3 additions & 3 deletions backend/src/mirrors_qa_backend/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main():
logger.info(
f"Expired test {expired_test.id}, "
f"country: {expired_test.country_code}, "
f"worker: {expired_test.worker_id!r}"
f"worker: {expired_test.worker_id}"
)

idle_workers = get_idle_workers(
Expand All @@ -35,7 +35,7 @@ def main():
for idle_worker in idle_workers:
if not idle_worker.countries:
logger.info(
f"No countries registered for idle worker {idle_worker.id!r}"
f"No countries registered for idle worker {idle_worker.id}"
)
continue
for country in idle_worker.countries:
Expand All @@ -53,7 +53,7 @@ def main():
if pending_tests.nb_tests:
logger.info(
"Skipping creation of new test entries for "
f"{idle_worker.id!r} as {pending_tests.nb_tests} "
f"{idle_worker.id} as {pending_tests.nb_tests} "
f"tests are still pending for country {country.name}"
)
continue
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def public_key(private_key: RSAPrivateKey) -> RSAPublicKey:


@pytest.fixture(scope="session")
def private_key_bytes(private_key: RSAPrivateKey) -> bytes:
def private_key_data(private_key: RSAPrivateKey) -> bytes:
return private_key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.PKCS8,
Expand Down
5 changes: 2 additions & 3 deletions backend/tests/db/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mirrors_qa_backend.db.worker import create_worker


def test_create_worker(dbsession: OrmSession, tmp_path: Path, private_key_bytes: bytes):
def test_create_worker(dbsession: OrmSession, tmp_path: Path, private_key_data: bytes):
worker_id = "test"
countries = [
Country(code="ng", name="Nigeria"),
Expand All @@ -15,8 +15,7 @@ def test_create_worker(dbsession: OrmSession, tmp_path: Path, private_key_bytes:
dbsession.add_all(countries)

private_key_fpath = tmp_path / "key.pem"
with private_key_fpath.open("wb") as key_file:
key_file.write(private_key_bytes)
private_key_fpath.write_bytes(private_key_data)

new_worker = create_worker(
dbsession,
Expand Down

0 comments on commit 9a8cea8

Please sign in to comment.