Skip to content

Commit a799d76

Browse files
committed
chore: fix linting issues + cleanup
1 parent ea3fce5 commit a799d76

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/firebase_functions/private/util.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def on_call_check_tokens(request: _Request,) -> _OnCallTokenVerification:
248248
@_dataclasses.dataclass(frozen=True)
249249
class FirebaseConfig():
250250
"""
251-
A collection of configuration options needed to
251+
A collection of configuration options needed to
252252
initialize a firebase App.
253253
"""
254254

@@ -265,22 +265,22 @@ def firebase_config() -> None | FirebaseConfig:
265265
config_file = _os.getenv("FIREBASE_CONFIG")
266266
if not config_file:
267267
return None
268-
if config_file.startswith('{'):
268+
if config_file.startswith("{"):
269269
json_str = config_file
270270
else:
271271
# Firebase Tools will always use a JSON blob in prod, but docs
272272
# explicitly state that the user can set the env to a file:
273273
# https://firebase.google.com/docs/admin/setup#initialize-without-parameters
274274
try:
275-
with open(config_file, 'r') as json_file:
275+
with open(config_file, "r", encoding="utf8") as json_file:
276276
json_str = json_file.read()
277277
except Exception as err:
278-
raise ValueError('Unable to read file {}. {}'.format(
279-
config_file, err))
278+
raise ValueError(
279+
f"Unable to read file {config_file}. {err}") from err
280280
try:
281281
json_data: dict = _json.loads(json_str)
282282
except Exception as err:
283283
raise ValueError(
284-
'FIREBASE_CONFIG JSON string "{0}" is not valid json. {1}'.format(
285-
json_str, err))
286-
return FirebaseConfig(storage_bucket=json_data.get('storageBucket'))
284+
f'FIREBASE_CONFIG JSON string "{json_str}" is not valid json. {err}'
285+
) from err
286+
return FirebaseConfig(storage_bucket=json_data.get("storageBucket"))

tests/test_util.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_firebase_config_loads_from_env_json():
2727
Testing firebase_config can be read from the
2828
FIREBASE_CONFIG env var as a JSON string.
2929
"""
30-
environ["FIREBASE_CONFIG"] = '{"storageBucket": "%s"}' % test_bucket
30+
environ["FIREBASE_CONFIG"] = f'{{"storageBucket": "{test_bucket}"}}'
3131
assert firebase_config().storage_bucket == test_bucket, (
3232
"Failure, firebase_config did not load from env variable.")
3333

@@ -39,4 +39,4 @@ def test_firebase_config_loads_from_env_file():
3939
"""
4040
environ["FIREBASE_CONFIG"] = test_config_file
4141
assert firebase_config().storage_bucket == test_bucket, (
42-
"Failure, firebase_config did not load from env variable.")
42+
"Failure, firebase_config did not load from env variable.")

0 commit comments

Comments
 (0)