Skip to content

Commit cce8fef

Browse files
committed
Auto-format using ruff
1 parent 9a0dbc8 commit cce8fef

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

tests/system/cli/test_sync.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,7 @@ def test_fetch_only_necessary_params(tmpdir, runner):
553553
type = "filesystem"
554554
path = "{path}"
555555
fileext.fetch = ["command", "sh", "{script}"]
556-
""".format(
557-
path=str(tmpdir.mkdir("bogus")), script=str(fetch_script)
558-
)
556+
""".format(path=str(tmpdir.mkdir("bogus")), script=str(fetch_script))
559557
)
560558
)
561559

tests/unit/utils/test_vobject.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,14 @@ def sanity_check(self, c):
364364

365365
TestVobjectMachine = VobjectMachine.TestCase
366366

367+
367368
def test_dupe_consecutive_keys():
368369
state = VobjectMachine()
369370
unparsed_0 = state.get_unparsed_lines(encoded=False, joined=False)
370371
parsed_0 = state.parse(unparsed=unparsed_0)
371-
state.add_prop_raw(c=parsed_0, key='0', params=[], value='0')
372-
state.add_prop_raw(c=parsed_0, key='0', params=[], value='0')
373-
state.add_prop(c=parsed_0, key='0', value='1')
372+
state.add_prop_raw(c=parsed_0, key="0", params=[], value="0")
373+
state.add_prop_raw(c=parsed_0, key="0", params=[], value="0")
374+
state.add_prop(c=parsed_0, key="0", value="1")
374375
state.teardown()
375376

376377

vdirsyncer/http.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import os
55
import platform
66
import re
7-
from abc import ABC, abstractmethod
7+
from abc import ABC
8+
from abc import abstractmethod
89
from base64 import b64encode
910
from ssl import create_default_context
1011

@@ -43,7 +44,11 @@ def get_auth_header(self, method, url):
4344
def __eq__(self, other):
4445
if not isinstance(other, AuthMethod):
4546
return False
46-
return self.__class__ == other.__class__ and self.username == other.username and self.password == other.password
47+
return (
48+
self.__class__ == other.__class__
49+
and self.username == other.username
50+
and self.password == other.password
51+
)
4752

4853

4954
class BasicAuthMethod(AuthMethod):
@@ -52,7 +57,7 @@ def handle_401(self, _response):
5257

5358
def get_auth_header(self, _method, _url):
5459
auth_str = f"{self.username}:{self.password}"
55-
return "Basic " + b64encode(auth_str.encode('utf-8')).decode("utf-8")
60+
return "Basic " + b64encode(auth_str.encode("utf-8")).decode("utf-8")
5661

5762

5863
class DigestAuthMethod(AuthMethod):
@@ -64,8 +69,7 @@ def __init__(self, username, password):
6469
super().__init__(username, password)
6570

6671
self._auth_helper = self._auth_helpers.get(
67-
(username, password),
68-
requests.auth.HTTPDigestAuth(username, password)
72+
(username, password), requests.auth.HTTPDigestAuth(username, password)
6973
)
7074
self._auth_helpers[(username, password)] = self._auth_helper
7175

@@ -87,7 +91,7 @@ def get_auth_header(self, method, url):
8791

8892
if not self.auth_helper_vars.chal:
8993
# Need to do init request first
90-
return ''
94+
return ""
9195

9296
return self._auth_helper.build_digest_header(method, url)
9397

@@ -99,10 +103,12 @@ def prepare_auth(auth, username, password):
99103
elif auth == "digest":
100104
return DigestAuthMethod(username, password)
101105
elif auth == "guess":
102-
raise exceptions.UserError(f"'Guess' authentication is not supported in this version of vdirsyncer. \n"
103-
f"Please explicitly specify either 'basic' or 'digest' auth instead. \n"
104-
f"See the following issue for more information: "
105-
f"https://github.com/pimutils/vdirsyncer/issues/1015")
106+
raise exceptions.UserError(
107+
"'Guess' authentication is not supported in this version of vdirsyncer. \n"
108+
"Please explicitly specify either 'basic' or 'digest' auth instead. \n"
109+
"See the following issue for more information: "
110+
"https://github.com/pimutils/vdirsyncer/issues/1015"
111+
)
106112
else:
107113
raise exceptions.UserError(f"Unknown authentication method: {auth}")
108114
elif auth:

vdirsyncer/storage/dav.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,7 @@ async def _create_collection_impl(self, url):
310310
</mkcol>
311311
""".format(
312312
etree.tostring(etree.Element(self._resourcetype), encoding="unicode")
313-
).encode(
314-
"utf-8"
315-
)
313+
).encode("utf-8")
316314

317315
response = await self.session.request(
318316
"MKCOL",
@@ -740,9 +738,7 @@ async def set_meta(self, key, value):
740738
""".format(
741739
etree.tostring(element, encoding="unicode"),
742740
action=action,
743-
).encode(
744-
"utf-8"
745-
)
741+
).encode("utf-8")
746742

747743
await self.session.request(
748744
"PROPPATCH",

0 commit comments

Comments
 (0)