Skip to content

Commit 13a692f

Browse files
authored
[style] F-strings are not necessary if there is no placeholder (#2307)
1 parent 9ee336d commit 13a692f

File tree

8 files changed

+38
-38
lines changed

8 files changed

+38
-38
lines changed

fixcore/tests/fixcore/cli/cli_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async def test_create_query_parts(cli: CLI) -> None:
203203
commands = await cli.evaluate_cli_command("search some_int==0 | aggregate foo, bla as bla: sum(bar) as a")
204204
assert (
205205
commands[0].executable_commands[0].arg
206-
== f"'aggregate(reported.foo, reported.bla as bla: sum(reported.bar) as a):reported.some_int == 0 sort a asc'"
206+
== "'aggregate(reported.foo, reported.bla as bla: sum(reported.bar) as a):reported.some_int == 0 sort a asc'"
207207
)
208208

209209
# multiple head/tail commands are combined correctly
@@ -216,7 +216,7 @@ async def test_create_query_parts(cli: CLI) -> None:
216216
commands = await cli.evaluate_cli_command("search is(volume) | tail -10")
217217
assert (
218218
commands[0].executable_commands[0].arg
219-
== f"'is(\"volume\") sort reported.kind desc, reported.name desc, reported.id desc limit 10 reversed '"
219+
== "'is(\"volume\") sort reported.kind desc, reported.name desc, reported.id desc limit 10 reversed '"
220220
)
221221
commands = await cli.evaluate_cli_command("search is(volume) sort name | tail -10 | head 5")
222222
assert commands[0].executable_commands[0].arg == "'is(\"volume\") sort reported.name desc limit 5, 5 reversed '"

fixcore/tests/fixcore/cli/command_test.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,21 +1017,21 @@ async def test_pagerduty_alias(cli: CLI, echo_http_server: Tuple[int, List[Tuple
10171017
@pytest.mark.asyncio
10181018
async def test_welcome(cli: CLI) -> None:
10191019
ctx = CLIContext(console_renderer=ConsoleRenderer.default_renderer())
1020-
result = await cli.execute_cli_command(f"welcome", list_sink, ctx)
1020+
result = await cli.execute_cli_command("welcome", list_sink, ctx)
10211021
assert "Fix" in result[0][0]
10221022

10231023

10241024
@pytest.mark.asyncio
10251025
async def test_tip_of_the_day(cli: CLI) -> None:
10261026
ctx = CLIContext(console_renderer=ConsoleRenderer.default_renderer())
1027-
result = await cli.execute_cli_command(f"totd", list_sink, ctx)
1027+
result = await cli.execute_cli_command("totd", list_sink, ctx)
10281028
assert generic_tips[0].command_line in result[0][0]
10291029

10301030

10311031
@pytest.mark.asyncio
10321032
async def test_certificate(cli: CLI) -> None:
10331033
result = await cli.execute_cli_command(
1034-
f"certificate create --common-name foo.inventory.fix.security --dns-names bla --ip-addresses 1.2.3.4 --days-valid 1",
1034+
"certificate create --common-name foo.inventory.fix.security --dns-names bla --ip-addresses 1.2.3.4 --days-valid 1",
10351035
list_sink,
10361036
)
10371037
# will create 2 files
@@ -1054,14 +1054,14 @@ async def test_execute_task(cli: CLI) -> None:
10541054

10551055
# execute-task in source position
10561056
source_result = await cli.execute_cli_command(
1057-
f'execute-task --command success_task --arg "--foo bla test"', list_sink
1057+
'execute-task --command success_task --arg "--foo bla test"', list_sink
10581058
)
10591059
assert len(source_result[0]) == 1
10601060
assert source_result[0] == [{"result": "done!"}]
10611061

10621062
# execute task in flow position: every incoming node creates a new task
10631063
flow_result = await cli.execute_cli_command(
1064-
f'search all limit 3 | execute-task --command success_task --arg "--t {{id}}"', list_sink
1064+
'search all limit 3 | execute-task --command success_task --arg "--t {id}"', list_sink
10651065
)
10661066
assert len(flow_result[0]) == 3
10671067

@@ -1077,15 +1077,15 @@ async def history_count(cmd: str) -> int:
10771077
five_min_later = utc_str(now + timedelta(minutes=5))
10781078
assert await history_count("history") == 112 # 112 inserts for the filled graph db
10791079
assert await history_count(f"history --after {five_min_ago}") == 112
1080-
assert await history_count(f"history --after 5m") == 112
1080+
assert await history_count("history --after 5m") == 112
10811081
assert await history_count(f"history --after {five_min_later}") == 0
10821082
assert await history_count(f"history --before {five_min_ago}") == 0
1083-
assert await history_count(f"history --before 5m") == 0
1084-
assert await history_count(f"history --change node_created") == 112
1085-
assert await history_count(f"history --change node_updated") == 0
1086-
assert await history_count(f"history --change node_deleted") == 0
1087-
assert await history_count(f"history --change node_created --change node_updated --change node_deleted") == 112
1088-
assert await history_count(f"history is(foo)") == 10
1083+
assert await history_count("history --before 5m") == 0
1084+
assert await history_count("history --change node_created") == 112
1085+
assert await history_count("history --change node_updated") == 0
1086+
assert await history_count("history --change node_deleted") == 0
1087+
assert await history_count("history --change node_created --change node_updated --change node_deleted") == 112
1088+
assert await history_count("history is(foo)") == 10
10891089
# combine all selectors
10901090
assert await history_count(f"history --after 5m --before {five_min_later} --change node_created is(foo)") == 10
10911091

@@ -1429,12 +1429,12 @@ async def check(streamer: JsStream) -> None:
14291429

14301430
# search with aggregation does not export anything
14311431
with pytest.raises(Exception):
1432-
await sync_and_check(f"search all | aggregate kind:sum(1) | db sync sqlite --database foo")
1432+
await sync_and_check("search all | aggregate kind:sum(1) | db sync sqlite --database foo")
14331433

14341434
# define all parameters and check the connection string
14351435
with pytest.raises(Exception) as ex:
14361436
await sync_and_check(
1437-
f"db sync sqlite --database db --host bla --port 1234 --user test --password check --arg foo=bla foo2=bla2",
1437+
"db sync sqlite --database db --host bla --port 1234 --user test --password check --arg foo=bla foo2=bla2",
14381438
expected_table_count=11,
14391439
)
14401440
assert "sqlite://test:check@bla:1234" in str(ex.value)

fixcore/tests/fixcore/dependencies_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def test_parse_override() -> None:
2424
def parse(args: str) -> List[Tuple[str, JsonElement]]:
2525
return parse_args(args.split()).config_override # type: ignore
2626

27-
assert parse(f"--override a=foo") == [("a", "foo")]
28-
assert parse(f"--override a=foo,bla") == [("a", ["foo", "bla"])]
29-
assert parse(f"--override a=foo,bla b=a,b,c") == [("a", ["foo", "bla"]), ("b", ["a", "b", "c"])]
30-
assert parse(f'--override a="value,with,comma,in,quotes"') == [("a", "value,with,comma,in,quotes")]
31-
assert parse(f'--override a=some,value,"with,comma"') == [("a", ["some", "value", "with,comma"])]
27+
assert parse("--override a=foo") == [("a", "foo")]
28+
assert parse("--override a=foo,bla") == [("a", ["foo", "bla"])]
29+
assert parse("--override a=foo,bla b=a,b,c") == [("a", ["foo", "bla"]), ("b", ["a", "b", "c"])]
30+
assert parse('--override a="value,with,comma,in,quotes"') == [("a", "value,with,comma,in,quotes")]
31+
assert parse('--override a=some,value,"with,comma"') == [("a", ["some", "value", "with,comma"])]
3232

3333

3434
class ExampleService(Service):

fixcore/tests/fixcore/model/model_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def test_datetime() -> None:
186186
assert a.coerce_if_required("12mo").startswith("20") # type: ignore
187187
with pytest.raises(Exception) as no_date:
188188
a.check_valid("simply no date")
189-
assert str(no_date.value) == f"Invalid isoformat string: 'simply no date'"
189+
assert str(no_date.value) == "Invalid isoformat string: 'simply no date'"
190190

191191

192192
def test_date() -> None:
@@ -199,7 +199,7 @@ def test_date() -> None:
199199
assert a.coerce_if_required("12mo").startswith("20") # type: ignore
200200
with pytest.raises(Exception) as no_date:
201201
a.check_valid("simply no date")
202-
assert str(no_date.value) == f"Invalid isoformat string: 'simply no date'"
202+
assert str(no_date.value) == "Invalid isoformat string: 'simply no date'"
203203

204204

205205
def test_dictionary() -> None:

fixcore/tests/fixcore/web/api_client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async def update_model(self, update: List[Kind]) -> Model:
3838
return model
3939

4040
async def list_graphs(self) -> Set[str]:
41-
async with self.session.get(self.base_path + f"/graph") as response:
41+
async with self.session.get(self.base_path + "/graph") as response:
4242
return set(await response.json())
4343

4444
async def get_graph(self, name: str) -> Optional[AccessJson]:
@@ -179,7 +179,7 @@ async def search_aggregate(self, graph: str, search: str) -> List[AccessJson]:
179179
raise AttributeError(await r.text())
180180

181181
async def subscribers(self) -> List[Subscriber]:
182-
async with self.session.get(self.base_path + f"/subscribers") as r:
182+
async with self.session.get(self.base_path + "/subscribers") as r:
183183
if r.status == 200:
184184
return from_js(await r.json(), List[Subscriber])
185185
else:
@@ -235,7 +235,7 @@ async def delete_subscriber(self, uid: str) -> None:
235235

236236
async def cli_evaluate(self, graph: str, command: str, **env: str) -> List[Tuple[ParsedCommands, List[AccessJson]]]:
237237
props = {"graph": graph, "section": "reported", **env}
238-
async with self.session.post(self.base_path + f"/cli/evaluate", data=command, params=props) as r:
238+
async with self.session.post(self.base_path + "/cli/evaluate", data=command, params=props) as r:
239239
if r.status == 200:
240240
return [
241241
(
@@ -249,21 +249,21 @@ async def cli_evaluate(self, graph: str, command: str, **env: str) -> List[Tuple
249249

250250
async def cli_execute(self, graph: str, command: str, **env: str) -> List[JsonElement]:
251251
props = {"graph": graph, "section": "reported", **env}
252-
async with self.session.post(self.base_path + f"/cli/execute", data=command, params=props) as r:
252+
async with self.session.post(self.base_path + "/cli/execute", data=command, params=props) as r:
253253
if r.status == 200:
254254
return AccessJson.wrap_list(await r.json()) # type: ignore
255255
else:
256256
raise AttributeError(await r.text())
257257

258258
async def cli_info(self) -> AccessJson:
259-
async with self.session.get(self.base_path + f"/cli/info") as r:
259+
async with self.session.get(self.base_path + "/cli/info") as r:
260260
if r.status == 200:
261261
return AccessJson.wrap_object(await r.json())
262262
else:
263263
raise AttributeError(await r.text())
264264

265265
async def configs(self) -> List[str]:
266-
async with self.session.get(self.base_path + f"/configs") as r:
266+
async with self.session.get(self.base_path + "/configs") as r:
267267
if r.status == 200:
268268
return AccessJson.wrap_list(await r.json()) # type: ignore
269269
else:
@@ -299,7 +299,7 @@ async def delete_config(self, config_id: str) -> None:
299299
raise AttributeError(await r.text())
300300

301301
async def get_configs_model(self) -> Model:
302-
async with self.session.get(self.base_path + f"/configs/model") as r:
302+
async with self.session.get(self.base_path + "/configs/model") as r:
303303
if r.status == 200:
304304
model_json = await r.json()
305305
model = Model.from_kinds([from_js(kind, Kind) for kind in model_json["kinds"].values()]) # type: ignore
@@ -326,14 +326,14 @@ async def put_config_validation(self, cfg: ConfigValidation) -> ConfigValidation
326326
return from_js(await response.json(), ConfigValidation)
327327

328328
async def ping(self) -> str:
329-
async with self.session.get(self.base_path + f"/system/ping") as r:
329+
async with self.session.get(self.base_path + "/system/ping") as r:
330330
if r.status == 200:
331331
return await r.text()
332332
else:
333333
raise AttributeError(await r.text())
334334

335335
async def ready(self) -> str:
336-
async with self.session.get(self.base_path + f"/system/ready") as r:
336+
async with self.session.get(self.base_path + "/system/ready") as r:
337337
if r.status == 200:
338338
return await r.text()
339339
else:

fixcore/tests/fixcore/web/api_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def create_core_client(
101101
"--no-scheduling",
102102
"--ignore-interrupted-tasks",
103103
"--override",
104-
f"fixcore.api.https_port=null",
104+
"fixcore.api.https_port=null",
105105
f"fixcore.api.http_port={http_port}",
106106
"fixcore.api.web_hosts=0.0.0.0",
107107
"fixcore.graph.use_view=false",

fixcore/tools/grapher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def node(level, identity, replace: bool = False, kind: Optional[str] = None):
4646
reported["kind"] = kind
4747
metadata = {"level": level}
4848
metadata = metadata | {"replace": True} if replace else metadata
49-
desired = {"name": f"some cool name", "age": 29}
49+
desired = {"name": "some cool name", "age": 29}
5050
js = {"id": identity, "reported": reported, "metadata": metadata, "desired": desired}
5151
# replace flag is now on metadata level
5252
# js = js | {"replace": True} if replace else js
@@ -57,7 +57,7 @@ def edge(from_node, to_node, edge_type):
5757
print(json.dumps({"from": from_node, "to": to_node, "edge_type": edge_type}))
5858

5959

60-
root = f"root"
60+
root = "root"
6161
collector_root = f"{collector}_root"
6262
node(0, root, kind="graph_root")
6363
node(0, collector_root, replace=True, kind="cloud")

fixcore/tools/render_dot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
from pathlib import Path
3131
import shlex
3232
except ImportError:
33-
print(f"Can't import one or more modules. Is fix dev environment activated?")
34-
print(f"Hint: see https://inventory.fix.security/docs/contributing/components for more info.")
33+
print("Can't import one or more modules. Is fix dev environment activated?")
34+
print("Hint: see https://inventory.fix.security/docs/contributing/components for more info.")
3535
exit(1)
3636

3737
JsonElement = Union[str, int, float, bool, None, Mapping[str, Any], Sequence[Any]]
@@ -221,7 +221,7 @@ def send_analytics(run_id: str, event: str):
221221
client.api_key = api_key
222222
for consumer in client.consumers:
223223
consumer.api_key = api_key
224-
system_id = f"dot-rendering-script"
224+
system_id = "dot-rendering-script"
225225
now = utc()
226226
client.identify(system_id, {"run_id": run_id, "created_at": now})
227227
client.capture(

0 commit comments

Comments
 (0)