Skip to content

Commit 301aa0e

Browse files
committed
pre-commit run --all
1 parent dcd3b7a commit 301aa0e

File tree

17 files changed

+81
-112
lines changed

17 files changed

+81
-112
lines changed

tests/storage/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ async def test_recurring_events(self, s, item_type):
383383
uid = str(uuid.uuid4())
384384
item = Item(
385385
textwrap.dedent(
386-
"""
386+
f"""
387387
BEGIN:VCALENDAR
388388
VERSION:2.0
389389
BEGIN:VEVENT
@@ -417,9 +417,7 @@ async def test_recurring_events(self, s, item_type):
417417
TRANSP:OPAQUE
418418
END:VEVENT
419419
END:VCALENDAR
420-
""".format(
421-
uid=uid
422-
)
420+
"""
423421
).strip()
424422
)
425423

tests/storage/dav/test_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def test_xml_utilities():
3939
def test_xml_specialchars(char):
4040
x = _parse_xml(
4141
'<?xml version="1.0" encoding="UTF-8" ?>'
42-
"<foo>ye{}s\r\n"
43-
"hello</foo>".format(chr(char)).encode("ascii")
42+
f"<foo>ye{chr(char)}s\r\n"
43+
"hello</foo>".encode("ascii")
4444
)
4545

4646
if char in _BAD_XML_CHARS:

tests/system/cli/test_discover.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,23 +152,21 @@ def test_discover_direct_path(tmpdir, runner):
152152
def test_null_collection_with_named_collection(tmpdir, runner):
153153
runner.write_with_general(
154154
dedent(
155-
"""
155+
f"""
156156
[pair foobar]
157157
a = "foo"
158158
b = "bar"
159159
collections = [["baz", "baz", null]]
160160
161161
[storage foo]
162162
type = "filesystem"
163-
path = "{base}/foo/"
163+
path = "{str(tmpdir)}/foo/"
164164
fileext = ".txt"
165165
166166
[storage bar]
167167
type = "singlefile"
168-
path = "{base}/bar.txt"
169-
""".format(
170-
base=str(tmpdir)
171-
)
168+
path = "{str(tmpdir)}/bar.txt"
169+
"""
172170
)
173171
)
174172

@@ -221,22 +219,20 @@ async def list(self) -> List[tuple]:
221219

222220
runner.write_with_general(
223221
dedent(
224-
"""
222+
f"""
225223
[pair foobar]
226224
a = "foo"
227225
b = "bar"
228226
collections = null
229227
230228
[storage foo]
231229
type = "test"
232-
require_collection = {a}
230+
require_collection = {json.dumps(a_requires)}
233231
234232
[storage bar]
235233
type = "test"
236-
require_collection = {b}
237-
""".format(
238-
a=json.dumps(a_requires), b=json.dumps(b_requires)
239-
)
234+
require_collection = {json.dumps(b_requires)}
235+
"""
240236
)
241237
)
242238

tests/system/cli/test_fetchparams.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44
def test_get_password_from_command(tmpdir, runner):
55
runner.write_with_general(
66
dedent(
7-
"""
7+
f"""
88
[pair foobar]
99
a = "foo"
1010
b = "bar"
1111
collections = ["a", "b", "c"]
1212
1313
[storage foo]
1414
type.fetch = ["shell", "echo filesystem"]
15-
path = "{base}/foo/"
15+
path = "{str(tmpdir)}/foo/"
1616
fileext.fetch = ["command", "echo", ".txt"]
1717
1818
[storage bar]
1919
type = "filesystem"
20-
path = "{base}/bar/"
20+
path = "{str(tmpdir)}/bar/"
2121
fileext.fetch = ["prompt", "Fileext for bar"]
22-
""".format(
23-
base=str(tmpdir)
24-
)
22+
"""
2523
)
2624
)
2725

tests/system/cli/test_sync.py

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -280,24 +280,22 @@ def get_cfg():
280280
def test_create_collections(collections, tmpdir, runner):
281281
runner.write_with_general(
282282
dedent(
283-
"""
283+
f"""
284284
[pair foobar]
285285
a = "foo"
286286
b = "bar"
287-
collections = {colls}
287+
collections = {json.dumps(list(collections))}
288288
289289
[storage foo]
290290
type = "filesystem"
291-
path = "{base}/foo/"
291+
path = "{str(tmpdir)}/foo/"
292292
fileext = ".txt"
293293
294294
[storage bar]
295295
type = "filesystem"
296-
path = "{base}/bar/"
296+
path = "{str(tmpdir)}/bar/"
297297
fileext = ".txt"
298-
""".format(
299-
base=str(tmpdir), colls=json.dumps(list(collections))
300-
)
298+
"""
301299
)
302300
)
303301

@@ -315,24 +313,22 @@ def test_create_collections(collections, tmpdir, runner):
315313
def test_ident_conflict(tmpdir, runner):
316314
runner.write_with_general(
317315
dedent(
318-
"""
316+
f"""
319317
[pair foobar]
320318
a = "foo"
321319
b = "bar"
322320
collections = null
323321
324322
[storage foo]
325323
type = "filesystem"
326-
path = "{base}/foo/"
324+
path = "{str(tmpdir)}/foo/"
327325
fileext = ".txt"
328326
329327
[storage bar]
330328
type = "filesystem"
331-
path = "{base}/bar/"
329+
path = "{str(tmpdir)}/bar/"
332330
fileext = ".txt"
333-
""".format(
334-
base=str(tmpdir)
335-
)
331+
"""
336332
)
337333
)
338334

@@ -371,19 +367,17 @@ def test_ident_conflict(tmpdir, runner):
371367
def test_unknown_storage(tmpdir, runner, existing, missing):
372368
runner.write_with_general(
373369
dedent(
374-
"""
370+
f"""
375371
[pair foobar]
376372
a = "foo"
377373
b = "bar"
378374
collections = null
379375
380376
[storage {existing}]
381377
type = "filesystem"
382-
path = "{base}/{existing}/"
378+
path = "{str(tmpdir)}/{existing}/"
383379
fileext = ".txt"
384-
""".format(
385-
base=str(tmpdir), existing=existing
386-
)
380+
"""
387381
)
388382
)
389383

@@ -393,10 +387,8 @@ def test_unknown_storage(tmpdir, runner, existing, missing):
393387
assert result.exception
394388

395389
assert (
396-
"Storage '{missing}' not found. "
397-
"These are the configured storages: ['{existing}']".format(
398-
missing=missing, existing=existing
399-
)
390+
f"Storage '{missing}' not found. "
391+
f"These are the configured storages: ['{existing}']"
400392
) in result.output
401393

402394

@@ -416,25 +408,23 @@ def test_no_configured_pairs(tmpdir, runner, cmd):
416408
def test_conflict_resolution(tmpdir, runner, resolution, expect_foo, expect_bar):
417409
runner.write_with_general(
418410
dedent(
419-
"""
411+
f"""
420412
[pair foobar]
421413
a = "foo"
422414
b = "bar"
423415
collections = null
424-
conflict_resolution = {val}
416+
conflict_resolution = {json.dumps(resolution)}
425417
426418
[storage foo]
427419
type = "filesystem"
428420
fileext = ".txt"
429-
path = "{base}/foo"
421+
path = "{str(tmpdir)}/foo"
430422
431423
[storage bar]
432424
type = "filesystem"
433425
fileext = ".txt"
434-
path = "{base}/bar"
435-
""".format(
436-
base=str(tmpdir), val=json.dumps(resolution)
437-
)
426+
path = "{str(tmpdir)}/bar"
427+
"""
438428
)
439429
)
440430

@@ -526,13 +516,11 @@ def test_fetch_only_necessary_params(tmpdir, runner):
526516
fetch_script = tmpdir.join("fetch_script")
527517
fetch_script.write(
528518
dedent(
529-
"""
519+
f"""
530520
set -e
531-
touch "{}"
521+
touch "{str(fetched_file)}"
532522
echo ".txt"
533-
""".format(
534-
str(fetched_file)
535-
)
523+
"""
536524
)
537525
)
538526

vdirsyncer/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
)
1818

1919

20-
def _check_python_version(): # pragma: no cover
20+
def _check_python_version():
2121
import sys
2222

23-
if sys.version_info < (3, 7, 0):
23+
if sys.version_info < (3, 7, 0): # noqa: UP036
2424
print("vdirsyncer requires at least Python 3.7.")
2525
sys.exit(1)
2626

vdirsyncer/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def app(ctx, config: str):
5454
cli_logger.warning(
5555
"Vdirsyncer currently does not support Windows. "
5656
"You will likely encounter bugs. "
57-
"See {}/535 for more information.".format(BUGTRACKER_HOME)
57+
f"See {BUGTRACKER_HOME}/535 for more information."
5858
)
5959

6060
if not ctx.config:

vdirsyncer/cli/config.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def validate_section_name(name, section_type):
2727
if invalid:
2828
chars_display = "".join(sorted(SECTION_NAME_CHARS))
2929
raise exceptions.UserError(
30-
'The {}-section "{}" contains invalid characters. Only '
30+
f'The {section_type}-section "{name}" contains invalid characters. Only '
3131
"the following characters are allowed for storage and "
32-
"pair names:\n{}".format(section_type, name, chars_display)
32+
f"pair names:\n{chars_display}"
3333
)
3434

3535

@@ -51,7 +51,7 @@ def _validate_general_section(general_config: dict[str, str]):
5151
if problems:
5252
raise exceptions.UserError(
5353
"Invalid general section. Copy the example "
54-
"config from the repository and edit it: {}".format(PROJECT_HOME),
54+
f"config from the repository and edit it: {PROJECT_HOME}",
5555
problems=problems,
5656
)
5757

@@ -210,10 +210,8 @@ def get_storage_args(self, storage_name: str):
210210
args = self.storages[storage_name]
211211
except KeyError:
212212
raise exceptions.UserError(
213-
"Storage {!r} not found. "
214-
"These are the configured storages: {}".format(
215-
storage_name, list(self.storages)
216-
)
213+
f"Storage {storage_name!r} not found. "
214+
f"These are the configured storages: {list(self.storages)}"
217215
)
218216
else:
219217
return expand_fetch_params(args)

vdirsyncer/cli/discover.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ async def collections_for_pair(
6666
elif rv:
6767
raise exceptions.UserError(
6868
"Detected change in config file, "
69-
"please run `vdirsyncer discover {}`.".format(pair.name)
69+
f"please run `vdirsyncer discover {pair.name}`."
7070
)
7171
else:
7272
raise exceptions.UserError(
73-
"Please run `vdirsyncer discover {}` "
74-
" before synchronization.".format(pair.name)
73+
f"Please run `vdirsyncer discover {pair.name}` "
74+
" before synchronization."
7575
)
7676

7777
logger.info(f"Discovering collections for pair {pair.name}")
@@ -271,8 +271,8 @@ async def _print_collections(
271271

272272
logger.debug("".join(traceback.format_tb(sys.exc_info()[2])))
273273
logger.warning(
274-
"Failed to discover collections for {}, use `-vdebug` "
275-
"to see the full traceback.".format(instance_name)
274+
f"Failed to discover collections for {instance_name}, use `-vdebug` "
275+
"to see the full traceback."
276276
)
277277
return
278278
logger.info(f"{instance_name}:")

vdirsyncer/cli/fetchparams.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ def _fetch_value(opts, key):
6565
else:
6666
if not rv:
6767
raise exceptions.UserError(
68-
"Empty value for {}, this most likely "
69-
"indicates an error.".format(key)
68+
f"Empty value for {key}, this most likely indicates an error."
7069
)
7170
password_cache[cache_key] = rv
7271
return rv

0 commit comments

Comments
 (0)