mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Update linting tools
This commit is contained in:
parent
fc4a02c0c9
commit
2b4496fea4
11 changed files with 14 additions and 20 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.5.0
|
rev: v5.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
args: [--markdown-linebreak-ext=md]
|
args: [--markdown-linebreak-ext=md]
|
||||||
|
|
@ -9,7 +9,7 @@ repos:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: debug-statements
|
- id: debug-statements
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: "v1.8.0"
|
rev: "v1.15.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
files: vdirsyncer/.*
|
files: vdirsyncer/.*
|
||||||
|
|
@ -18,7 +18,7 @@ repos:
|
||||||
- types-docutils
|
- types-docutils
|
||||||
- types-requests
|
- types-requests
|
||||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||||
rev: 'v0.2.2'
|
rev: 'v0.11.4'
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ SPDX-License-Identifier: BSD-3-Clause
|
||||||
SPDX-FileCopyrightText: 2021 Intevation GmbH <https://intevation.de>
|
SPDX-FileCopyrightText: 2021 Intevation GmbH <https://intevation.de>
|
||||||
Author: <bernhard.reiter@intevation.de>
|
Author: <bernhard.reiter@intevation.de>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,7 @@ except ImportError:
|
||||||
html_theme = "default"
|
html_theme = "default"
|
||||||
if not on_rtd:
|
if not on_rtd:
|
||||||
print("-" * 74)
|
print("-" * 74)
|
||||||
print(
|
print("Warning: sphinx-rtd-theme not installed, building with default theme.")
|
||||||
"Warning: sphinx-rtd-theme not installed, building with default " "theme."
|
|
||||||
)
|
|
||||||
print("-" * 74)
|
print("-" * 74)
|
||||||
|
|
||||||
html_static_path = ["_static"]
|
html_static_path = ["_static"]
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,7 @@ def test_empty_storage(tmpdir, runner):
|
||||||
result = runner.invoke(["sync"])
|
result = runner.invoke(["sync"])
|
||||||
lines = result.output.splitlines()
|
lines = result.output.splitlines()
|
||||||
assert lines[0] == "Syncing my_pair"
|
assert lines[0] == "Syncing my_pair"
|
||||||
assert lines[1].startswith(
|
assert lines[1].startswith('error: my_pair: Storage "my_b" was completely emptied.')
|
||||||
"error: my_pair: " 'Storage "my_b" was completely emptied.'
|
|
||||||
)
|
|
||||||
assert result.exception
|
assert result.exception
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ def test_hash_item():
|
||||||
|
|
||||||
|
|
||||||
def test_multiline_uid(benchmark):
|
def test_multiline_uid(benchmark):
|
||||||
a = "BEGIN:FOO\r\n" "UID:123456789abcd\r\n" " efgh\r\n" "END:FOO\r\n"
|
a = "BEGIN:FOO\r\nUID:123456789abcd\r\n efgh\r\nEND:FOO\r\n"
|
||||||
assert benchmark(lambda: vobject.Item(a).uid) == "123456789abcdefgh"
|
assert benchmark(lambda: vobject.Item(a).uid) == "123456789abcdefgh"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ def _resolve_conflict_via_command(
|
||||||
new_b = f.read()
|
new_b = f.read()
|
||||||
|
|
||||||
if new_a != new_b:
|
if new_a != new_b:
|
||||||
raise exceptions.UserError("The two files are not completely " "equal.")
|
raise exceptions.UserError("The two files are not completely equal.")
|
||||||
return Item(new_a)
|
return Item(new_a)
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(dir)
|
shutil.rmtree(dir)
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,7 @@ async def collections_for_pair(
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise exceptions.UserError(
|
raise exceptions.UserError(
|
||||||
f"Please run `vdirsyncer discover {pair.name}` "
|
f"Please run `vdirsyncer discover {pair.name}` before synchronization."
|
||||||
" before synchronization."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(f"Discovering collections for pair {pair.name}")
|
logger.info(f"Discovering collections for pair {pair.name}")
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,7 @@ def repair_item(href, item, seen_uids, repair_unsafe_uid):
|
||||||
new_item = item.with_uid(generate_href())
|
new_item = item.with_uid(generate_href())
|
||||||
elif not href_safe(item.uid) or not href_safe(basename(href)):
|
elif not href_safe(item.uid) or not href_safe(basename(href)):
|
||||||
if not repair_unsafe_uid:
|
if not repair_unsafe_uid:
|
||||||
logger.warning(
|
logger.warning("UID may cause problems, add --repair-unsafe-uid to repair.")
|
||||||
"UID may cause problems, add " "--repair-unsafe-uid to repair."
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
logger.warning("UID or href is unsafe, assigning random UID.")
|
logger.warning("UID or href is unsafe, assigning random UID.")
|
||||||
new_item = item.with_uid(generate_href())
|
new_item = item.with_uid(generate_href())
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ class Discover:
|
||||||
|
|
||||||
href = response.find("{DAV:}href")
|
href = response.find("{DAV:}href")
|
||||||
if href is None:
|
if href is None:
|
||||||
raise InvalidXMLResponse("Missing href tag for collection " "props.")
|
raise InvalidXMLResponse("Missing href tag for collection props.")
|
||||||
href = urlparse.urljoin(str(r.url), href.text)
|
href = urlparse.urljoin(str(r.url), href.text)
|
||||||
if href not in done:
|
if href not in done:
|
||||||
done.add(href)
|
done.add(href)
|
||||||
|
|
@ -792,7 +792,7 @@ class CalDAVStorage(DAVStorage):
|
||||||
self.item_types = tuple(item_types)
|
self.item_types = tuple(item_types)
|
||||||
if (start_date is None) != (end_date is None):
|
if (start_date is None) != (end_date is None):
|
||||||
raise exceptions.UserError(
|
raise exceptions.UserError(
|
||||||
"If start_date is given, " "end_date has to be given too."
|
"If start_date is given, end_date has to be given too."
|
||||||
)
|
)
|
||||||
elif start_date is not None and end_date is not None:
|
elif start_date is not None and end_date is not None:
|
||||||
namespace = dict(datetime.__dict__)
|
namespace = dict(datetime.__dict__)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ class SingleFileStorage(Storage):
|
||||||
path = path % (collection,)
|
path = path % (collection,)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Exactly one %s required in path " "if collection is not null."
|
"Exactly one %s required in path if collection is not null."
|
||||||
)
|
)
|
||||||
|
|
||||||
checkfile(path, create=True)
|
checkfile(path, create=True)
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,7 @@ def open_graphical_browser(url, new=0, autoraise=True):
|
||||||
if browser.open(url, new, autoraise):
|
if browser.open(url, new, autoraise):
|
||||||
return
|
return
|
||||||
|
|
||||||
raise RuntimeError("No graphical browser found. Please open the URL " "manually.")
|
raise RuntimeError("No graphical browser found. Please open the URL manually.")
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue