Skip to content

Commit 6fcace7

Browse files
committed
style: applied pyupgrade --py37-plus aw_core/**.py aw_datastore/**.py aw_query/**.py aw_transform/**.py
1 parent ab7efc8 commit 6fcace7

File tree

12 files changed

+25
-25
lines changed

12 files changed

+25
-25
lines changed

aw_core/config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ def load_config_toml(
4141
appname: str, default_config: str
4242
) -> Union[dict, tomlkit.container.Container]:
4343
config_dir = dirs.get_config_dir(appname)
44-
config_file_path = os.path.join(config_dir, "{}.toml".format(appname))
44+
config_file_path = os.path.join(config_dir, f"{appname}.toml")
4545

4646
# Run early to ensure input is valid toml before writing
4747
default_config_toml = tomlkit.parse(default_config)
4848

4949
# Override defaults from existing config file
5050
if os.path.isfile(config_file_path):
51-
with open(config_file_path, "r") as f:
51+
with open(config_file_path) as f:
5252
config = f.read()
5353
config_toml = tomlkit.parse(config)
5454
else:
@@ -67,7 +67,7 @@ def save_config_toml(appname: str, config: str) -> None:
6767
assert tomlkit.parse(config)
6868

6969
config_dir = dirs.get_config_dir(appname)
70-
config_file_path = os.path.join(config_dir, "{}.toml".format(appname))
70+
config_file_path = os.path.join(config_dir, f"{appname}.toml")
7171

7272
with open(config_file_path, "w") as f:
7373
f.write(config)
@@ -86,11 +86,11 @@ def load_config(appname, default_config):
8686
config = default_config
8787

8888
config_dir = dirs.get_config_dir(appname)
89-
config_file_path = os.path.join(config_dir, "{}.toml".format(appname))
89+
config_file_path = os.path.join(config_dir, f"{appname}.toml")
9090

9191
# Override defaults from existing config file
9292
if os.path.isfile(config_file_path):
93-
with open(config_file_path, "r") as f:
93+
with open(config_file_path) as f:
9494
config.read_file(f)
9595

9696
# Overwrite current config file (necessary in case new default would be added)
@@ -106,7 +106,7 @@ def load_config(appname, default_config):
106106
)
107107
def save_config(appname, config):
108108
config_dir = dirs.get_config_dir(appname)
109-
config_file_path = os.path.join(config_dir, "{}.ini".format(appname))
109+
config_file_path = os.path.join(config_dir, f"{appname}.ini")
110110
with open(config_file_path, "w") as f:
111111
config.write(f)
112112
# Flush and fsync to lower risk of corrupted files

aw_core/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def g(*args, **kwargs):
4444
except exception as e:
4545
# TODO: Use warnings module instead?
4646
logging.error(
47-
"{} crashed due to exception, restarting.".format(f.__name__)
47+
f"{f.__name__} crashed due to exception, restarting."
4848
)
4949
logging.error(e)
5050
time.sleep(

aw_core/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def _create_json_formatter() -> logging.Formatter: # pragma: no cover
141141

142142
def log_format(x):
143143
"""Used to give JsonFormatter proper parameter format"""
144-
return ["%({0:s})".format(i) for i in x]
144+
return [f"%({i:s})" for i in x]
145145

146146
custom_format = " ".join(log_format(supported_keys))
147147

aw_core/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _timestamp_parse(ts_in: ConvertableTimestamp) -> datetime:
3030
if not ts.tzinfo:
3131
# Needed? All timestamps should be iso8601 so ought to always contain timezone.
3232
# Yes, because it is optional in iso8601
33-
logger.warning("timestamp without timezone found, using UTC: {}".format(ts))
33+
logger.warning(f"timestamp without timezone found, using UTC: {ts}")
3434
ts = ts.replace(tzinfo=timezone.utc)
3535
return ts
3636

@@ -137,5 +137,5 @@ def duration(self, duration: Duration) -> None:
137137
self["duration"] = timedelta(seconds=duration) # type: ignore
138138
else:
139139
raise TypeError(
140-
"Couldn't parse duration of invalid type {}".format(type(duration))
140+
f"Couldn't parse duration of invalid type {type(duration)}"
141141
)

aw_core/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ def assert_version(required_version: Tuple[int, ...] = (3, 5)): # pragma: no co
2222
+ " version to at least {}."
2323
).format(required_version)
2424
)
25-
logger.debug("Python version: {}".format(_version_info_tuple()))
25+
logger.debug(f"Python version: {_version_info_tuple()}")

aw_datastore/benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ def benchmark(storage: Callable[..., AbstractStorage]):
5959

6060
with temporary_bucket(ds) as bucket:
6161
with ttt(" sum"):
62-
with ttt(" single insert {} events".format(num_single_events)):
62+
with ttt(f" single insert {num_single_events} events"):
6363
for event in single_events:
6464
bucket.insert(event)
6565

66-
with ttt(" bulk insert {} events".format(num_bulk_events)):
66+
with ttt(f" bulk insert {num_bulk_events} events"):
6767
bucket.insert(bulk_events)
6868

69-
with ttt(" replace last {}".format(num_replace_events)):
69+
with ttt(f" replace last {num_replace_events}"):
7070
for e in replace_events:
7171
bucket.replace_last(e)
7272

aw_datastore/datastore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ def create_bucket(
5252
created: datetime = datetime.now(timezone.utc),
5353
name: Optional[str] = None,
5454
) -> "Bucket":
55-
self.logger.info("Creating bucket '{}'".format(bucket_id))
55+
self.logger.info(f"Creating bucket '{bucket_id}'")
5656
self.storage_strategy.create_bucket(
5757
bucket_id, type, client, hostname, created.isoformat(), name=name
5858
)
5959
return self[bucket_id]
6060

6161
def delete_bucket(self, bucket_id: str):
62-
self.logger.info("Deleting bucket '{}'".format(bucket_id))
62+
self.logger.info(f"Deleting bucket '{bucket_id}'")
6363
if bucket_id in self.bucket_instances:
6464
del self.bucket_instances[bucket_id]
6565
return self.storage_strategy.delete_bucket(bucket_id)

aw_datastore/migration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def detect_db_files(
2323
db_files = [
2424
filename
2525
for filename in db_files
26-
if filename.split(".")[1] == "v{}".format(version)
26+
if filename.split(".")[1] == f"v{version}"
2727
]
2828
return db_files
2929

@@ -49,7 +49,7 @@ def peewee_v2_to_sqlite_v1(datastore):
4949
buckets = pw_db.buckets()
5050
# Insert buckets and events to new db
5151
for bucket_id in buckets:
52-
logger.info("Migrating bucket {}".format(bucket_id))
52+
logger.info(f"Migrating bucket {bucket_id}")
5353
bucket = buckets[bucket_id]
5454
datastore.create_bucket(
5555
bucket["id"],

aw_datastore/storages/peewee.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ def __init__(self, testing: bool = True, filepath: str = None) -> None:
117117
filename = (
118118
"peewee-sqlite"
119119
+ ("-testing" if testing else "")
120-
+ ".v{}".format(LATEST_VERSION)
120+
+ f".v{LATEST_VERSION}"
121121
+ ".db"
122122
)
123123
filepath = os.path.join(data_dir, filename)
124124
self.db = _db
125125
self.db.init(filepath)
126-
logger.info("Using database file: {}".format(filepath))
126+
logger.info(f"Using database file: {filepath}")
127127

128128
self.db.connect()
129129

aw_datastore/storages/sqlite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ def __init__(self, testing, filepath: str = None, enable_lazy_commit=True) -> No
6767
ds_name = self.sid + ("-testing" if testing else "")
6868
if not filepath:
6969
data_dir = get_data_dir("aw-server")
70-
filename = ds_name + ".v{}".format(LATEST_VERSION) + ".db"
70+
filename = ds_name + f".v{LATEST_VERSION}" + ".db"
7171
filepath = os.path.join(data_dir, filename)
7272

7373
new_db_file = not os.path.exists(filepath)
7474
self.conn = sqlite3.connect(filepath)
75-
logger.info("Using database file: {}".format(filepath))
75+
logger.info(f"Using database file: {filepath}")
7676

7777
# Create tables
7878
self.conn.execute(CREATE_BUCKETS_TABLE)

0 commit comments

Comments
 (0)