Skip to content

Commit

Permalink
remove unnecessary implicit string concatenations
Browse files Browse the repository at this point in the history
  • Loading branch information
helylle committed Sep 19, 2024
1 parent 13974d5 commit d0e89a0
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/eduid/graphdb/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_create_db(self):
with self.neo4jdb.driver.session() as session:
session.run("CREATE (n:Test $props)", props={"name": "test node", "testing": True})
with self.neo4jdb.driver.session() as session:
result = session.run("MATCH (n {name: $name})" "RETURN n.testing", name="test node")
result = session.run("MATCH (n {name: $name})RETURN n.testing", name="test node")
self.assertTrue(result.single().value())


Expand All @@ -33,5 +33,5 @@ def test_base_db(self):
with test_db._db.driver.session() as session:
session.run("CREATE (n:Test $props)", props={"name": "test node", "testing": True})
with test_db._db.driver.session() as session:
result = session.run("MATCH (n {name: $name})" "RETURN n.testing", name="test node")
result = session.run("MATCH (n {name: $name})RETURN n.testing", name="test node")
self.assertTrue(result.single().value())
2 changes: 1 addition & 1 deletion src/eduid/userdb/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_uri_with_replicaset(self):
self.assertEqual(mdb.sanitized_uri, "mongodb://john:[email protected]/testdb?replicaset=rs9")
self.assertEqual(
mdb._db_uri,
"mongodb://john:[email protected],db2.example.com,db3.example.com:1234" "/testdb?replicaset=rs9",
"mongodb://john:[email protected],db2.example.com,db3.example.com:1234/testdb?replicaset=rs9",
)

def test_uri_with_options(self):
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/vccs/server/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def save(self, credential: Credential) -> bool:
logger.debug(f"Updated credential {credential} in the db (to revision {credential.revision}): {result}")
return True
logger.warning(
f"Could not update credential {credential} (to revision {credential.revision}): " f"{result.raw_result}"
f"Could not update credential {credential} (to revision {credential.revision}): {result.raw_result}"
)
credential.revision -= 1
return False
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/vccs/server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def startup_event():
if _name == "uvicorn.access":
_logger.propagate = False
app.logger.info(
f"Updated logger {_name} handlers {_old_handlers} -> {_logger.handlers} " f"(prop: {_logger.propagate})"
f"Updated logger {_name} handlers {_old_handlers} -> {_logger.handlers} (prop: {_logger.propagate})"
)


Expand Down
2 changes: 1 addition & 1 deletion src/eduid/webapp/authn/tests/test_authn.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ def test_no_cookie(self):
self.assertTrue(resp.location.startswith(self.app.conf.authn_service_url))

def test_cookie(self):
sessid = "fb1f42420b0109020203325d750185673df252de388932a3957f522a6c43a" "a47"
sessid = "fb1f42420b0109020203325d750185673df252de388932a3957f522a6c43aa47"
self.redis_instance.conn.set(sessid, json.dumps({"v1": {"id": "0"}}))

with self.session_cookie(self.browser, self.test_user.eppn) as c:
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/webapp/common/api/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def cached_json_response(key: str, data: dict[str, Any] | None = None) -> Respon
if SIMPLE_CACHE.get(key) is not None:
if now < SIMPLE_CACHE[key].expire_time:
if get_from_current_app("debug", bool):
logger.debug(f"Returned cached response for {key}" f" {now} < {SIMPLE_CACHE[key].expire_time}")
logger.debug(f"Returned cached response for {key} {now} < {SIMPLE_CACHE[key].expire_time}")
response = jsonify(SIMPLE_CACHE[key].data)
response.headers.add("Expires", SIMPLE_CACHE[key].expire_time.strftime("%a, %d %b %Y %H:%M:%S UTC"))
response.headers.add("Cache-Control", f"public,max-age={cache_for_seconds}")
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/webapp/email/verifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def send_verification_code(email: str, user: User) -> bool:
# Debug-log the code and message in development environment
current_app.logger.debug(f"code: {state.verification.verification_code}")
current_app.logger.debug(f"Generating verification e-mail with context:\n{payload}")
current_app.logger.info(f"Sent email address verification mail to user {user}" f" about address {email!s}.")
current_app.logger.info(f"Sent email address verification mail to user {user} about address {email!s}.")
return True


Expand Down
8 changes: 4 additions & 4 deletions src/eduid/webapp/email/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def verify(user: User, code: str, email: str) -> FluxData:
@require_user
def post_remove(user, email):
proofing_user = ProofingUser.from_user(user, current_app.private_userdb)
current_app.logger.debug(f"Trying to remove email address {email!r} " f"from user {proofing_user}")
current_app.logger.debug(f"Trying to remove email address {email!r} from user {proofing_user}")

# Do not let the user remove all mail addresses
if proofing_user.mail_addresses.count == 1:
Expand Down Expand Up @@ -184,17 +184,17 @@ def post_remove(user, email):
@MarshalWith(EmailResponseSchema)
@require_user
def resend_code(user: User, email: str) -> FluxData:
current_app.logger.debug("Trying to send new verification code for email " f"address {email} for user {user}")
current_app.logger.debug(f"Trying to send new verification code for email address {email} for user {user}")

if not user.mail_addresses.find(email):
current_app.logger.debug(f"Unknown email {email!r} in resend_code_action," f" user {user}")
current_app.logger.debug(f"Unknown email {email!r} in resend_code_action, user {user}")
return error_response(message=CommonMsg.out_of_sync)

sent = send_verification_code(email, user)
if not sent:
return error_response(message=EmailMsg.still_valid_code)

current_app.logger.debug("New verification code sent to " f"address {email} for user {user}")
current_app.logger.debug(f"New verification code sent to address {email} for user {user}")
current_app.stats.count(name="email_resend_code", value=1)

emails = {"emails": user.mail_addresses.to_list_of_dicts()}
Expand Down
4 changes: 1 addition & 3 deletions src/eduid/webapp/idp/sso_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ def _lookup_sso_session(sso_sessions: SSOSessionCache) -> SSOSession | None:
# Debug issues with browsers not returning updated SSO cookie values.
# Only log partial cookie value since it allows impersonation if leaked.
_other_session_id = SSOSessionId(session.idp.sso_cookie_val)
logger.debug(
"Found potential sso_cookie_val in the eduID session: " f"({session.idp.sso_cookie_val[:8]}...)"
)
logger.debug(f"Found potential sso_cookie_val in the eduID session: ({session.idp.sso_cookie_val[:8]}...)")
_other_sso = sso_sessions.get_session(_other_session_id)
if _other_sso is not None:
logger.info(f"Found no SSO session, but found one from session.idp.sso_cookie_val: {_other_sso}")
Expand Down
4 changes: 1 addition & 3 deletions src/eduid/webapp/oidc_proofing/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ def handle_freja_eid_userinfo(user: User, proofing_state: OidcProofingState, use
opaque = userinfo["results"]["freja_eid"]["opaque"]
transaction_id = userinfo["results"]["freja_eid"]["ref"]
if not number_match_proofing(user, proofing_state, number):
current_app.logger.warning(
"Proofing state number did not match number in userinfo." "Using number from userinfo."
)
current_app.logger.warning("Proofing state number did not match number in userinfo.Using number from userinfo.")
proofing_state.nin.number = number

current_app.logger.info(f"Getting address for user {user}")
Expand Down
2 changes: 1 addition & 1 deletion src/eduid/workers/amapi/routers/utils/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_cached_response(ctx: ContextRequest, resp: Response, key: str) -> Mappin
if now < SIMPLE_CACHE[key].expire_time:
if ctx.app.context.config.debug:
ctx.app.context.logger.debug(
f"Returned cached response for {key}" f" {now} < {SIMPLE_CACHE[key].expire_time}"
f"Returned cached response for {key} {now} < {SIMPLE_CACHE[key].expire_time}"
)
resp.headers["Expires"] = SIMPLE_CACHE[key].expire_time.strftime("%a, %d %b %Y %H:%M:%S UTC")
return SIMPLE_CACHE[key].data
Expand Down

0 comments on commit d0e89a0

Please sign in to comment.