Skip to content

Commit d2d41e5

Browse files
author
Hugo Osvaldo Barrera
committed
Use black to auto-format the codebase
1 parent abf199f commit d2d41e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2913
-2508
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ repos:
1313
hooks:
1414
- id: flake8
1515
additional_dependencies: [flake8-import-order, flake8-bugbear]
16+
- repo: https://github.com/psf/black
17+
rev: "21.5b0"
18+
hooks:
19+
- id: black
1620
- repo: https://github.com/asottile/reorder_python_imports
1721
rev: v2.5.0
1822
hooks:

docs/conf.py

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,90 +3,104 @@
33

44
from pkg_resources import get_distribution
55

6-
extensions = ['sphinx.ext.autodoc']
6+
extensions = ["sphinx.ext.autodoc"]
77

8-
templates_path = ['_templates']
8+
templates_path = ["_templates"]
99

10-
source_suffix = '.rst'
11-
master_doc = 'index'
10+
source_suffix = ".rst"
11+
master_doc = "index"
1212

13-
project = 'vdirsyncer'
14-
copyright = ('2014-{}, Markus Unterwaditzer & contributors'
15-
.format(datetime.date.today().strftime('%Y')))
13+
project = "vdirsyncer"
14+
copyright = "2014-{}, Markus Unterwaditzer & contributors".format(
15+
datetime.date.today().strftime("%Y")
16+
)
1617

17-
release = get_distribution('vdirsyncer').version
18-
version = '.'.join(release.split('.')[:2]) # The short X.Y version.
18+
release = get_distribution("vdirsyncer").version
19+
version = ".".join(release.split(".")[:2]) # The short X.Y version.
1920

20-
rst_epilog = '.. |vdirsyncer_version| replace:: %s' % release
21+
rst_epilog = ".. |vdirsyncer_version| replace:: %s" % release
2122

22-
exclude_patterns = ['_build']
23+
exclude_patterns = ["_build"]
2324

24-
pygments_style = 'sphinx'
25+
pygments_style = "sphinx"
2526

26-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
27+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
2728

2829
try:
2930
import sphinx_rtd_theme
30-
html_theme = 'sphinx_rtd_theme'
31+
32+
html_theme = "sphinx_rtd_theme"
3133
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
3234
except ImportError:
33-
html_theme = 'default'
35+
html_theme = "default"
3436
if not on_rtd:
35-
print('-' * 74)
36-
print('Warning: sphinx-rtd-theme not installed, building with default '
37-
'theme.')
38-
print('-' * 74)
37+
print("-" * 74)
38+
print(
39+
"Warning: sphinx-rtd-theme not installed, building with default " "theme."
40+
)
41+
print("-" * 74)
3942

40-
html_static_path = ['_static']
41-
htmlhelp_basename = 'vdirsyncerdoc'
43+
html_static_path = ["_static"]
44+
htmlhelp_basename = "vdirsyncerdoc"
4245

4346
latex_elements = {}
4447
latex_documents = [
45-
('index', 'vdirsyncer.tex', 'vdirsyncer Documentation',
46-
'Markus Unterwaditzer', 'manual'),
48+
(
49+
"index",
50+
"vdirsyncer.tex",
51+
"vdirsyncer Documentation",
52+
"Markus Unterwaditzer",
53+
"manual",
54+
),
4755
]
4856

4957
man_pages = [
50-
('index', 'vdirsyncer', 'vdirsyncer Documentation',
51-
['Markus Unterwaditzer'], 1)
58+
("index", "vdirsyncer", "vdirsyncer Documentation", ["Markus Unterwaditzer"], 1)
5259
]
5360

5461
texinfo_documents = [
55-
('index', 'vdirsyncer', 'vdirsyncer Documentation',
56-
'Markus Unterwaditzer', 'vdirsyncer',
57-
'Synchronize calendars and contacts.', 'Miscellaneous'),
62+
(
63+
"index",
64+
"vdirsyncer",
65+
"vdirsyncer Documentation",
66+
"Markus Unterwaditzer",
67+
"vdirsyncer",
68+
"Synchronize calendars and contacts.",
69+
"Miscellaneous",
70+
),
5871
]
5972

6073

61-
def github_issue_role(name, rawtext, text, lineno, inliner,
62-
options=None, content=()):
74+
def github_issue_role(name, rawtext, text, lineno, inliner, options=None, content=()):
6375
options = options or {}
6476
try:
6577
issue_num = int(text)
6678
if issue_num <= 0:
6779
raise ValueError()
6880
except ValueError:
69-
msg = inliner.reporter.error(f'Invalid GitHub issue: {text}',
70-
line=lineno)
81+
msg = inliner.reporter.error(f"Invalid GitHub issue: {text}", line=lineno)
7182
prb = inliner.problematic(rawtext, rawtext, msg)
7283
return [prb], [msg]
7384

7485
from docutils import nodes
7586

76-
PROJECT_HOME = 'https://github.com/pimutils/vdirsyncer'
77-
link = '{}/{}/{}'.format(PROJECT_HOME,
78-
'issues' if name == 'gh' else 'pull',
79-
issue_num)
80-
linktext = ('issue #{}' if name == 'gh'
81-
else 'pull request #{}').format(issue_num)
82-
node = nodes.reference(rawtext, linktext, refuri=link,
83-
**options)
87+
PROJECT_HOME = "https://github.com/pimutils/vdirsyncer"
88+
link = "{}/{}/{}".format(
89+
PROJECT_HOME, "issues" if name == "gh" else "pull", issue_num
90+
)
91+
linktext = ("issue #{}" if name == "gh" else "pull request #{}").format(issue_num)
92+
node = nodes.reference(rawtext, linktext, refuri=link, **options)
8493
return [node], []
8594

8695

8796
def setup(app):
8897
from sphinx.domains.python import PyObject
89-
app.add_object_type('storage', 'storage', 'pair: %s; storage',
90-
doc_field_types=PyObject.doc_field_types)
91-
app.add_role('gh', github_issue_role)
92-
app.add_role('ghpr', github_issue_role)
98+
99+
app.add_object_type(
100+
"storage",
101+
"storage",
102+
"pair: %s; storage",
103+
doc_field_types=PyObject.doc_field_types,
104+
)
105+
app.add_role("gh", github_issue_role)
106+
app.add_role("ghpr", github_issue_role)

setup.py

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
'''
1+
"""
22
Vdirsyncer synchronizes calendars and contacts.
33
44
Please refer to https://vdirsyncer.pimutils.org/en/stable/packaging.html for
55
how to package vdirsyncer.
6-
'''
6+
"""
77
from setuptools import Command
88
from setuptools import find_packages
99
from setuptools import setup
1010

1111

1212
requirements = [
1313
# https://github.com/mitsuhiko/click/issues/200
14-
'click>=5.0',
15-
'click-log>=0.3.0, <0.4.0',
16-
14+
"click>=5.0",
15+
"click-log>=0.3.0, <0.4.0",
1716
# https://github.com/pimutils/vdirsyncer/issues/478
18-
'click-threading>=0.2',
19-
20-
'requests >=2.20.0',
21-
17+
"click-threading>=0.2",
18+
"requests >=2.20.0",
2219
# https://github.com/sigmavirus24/requests-toolbelt/pull/28
2320
# And https://github.com/sigmavirus24/requests-toolbelt/issues/54
24-
'requests_toolbelt >=0.4.0',
25-
21+
"requests_toolbelt >=0.4.0",
2622
# https://github.com/untitaker/python-atomicwrites/commit/4d12f23227b6a944ab1d99c507a69fdbc7c9ed6d # noqa
27-
'atomicwrites>=0.1.7'
23+
"atomicwrites>=0.1.7",
2824
]
2925

3026

3127
class PrintRequirements(Command):
32-
description = 'Prints minimal requirements'
28+
description = "Prints minimal requirements"
3329
user_options = []
3430

3531
def initialize_options(self):
@@ -43,54 +39,44 @@ def run(self):
4339
print(requirement.replace(">", "=").replace(" ", ""))
4440

4541

46-
with open('README.rst') as f:
42+
with open("README.rst") as f:
4743
long_description = f.read()
4844

4945

5046
setup(
5147
# General metadata
52-
name='vdirsyncer',
53-
author='Markus Unterwaditzer',
54-
author_email='[email protected]',
55-
url='https://github.com/pimutils/vdirsyncer',
56-
description='Synchronize calendars and contacts',
57-
license='BSD',
48+
name="vdirsyncer",
49+
author="Markus Unterwaditzer",
50+
author_email="[email protected]",
51+
url="https://github.com/pimutils/vdirsyncer",
52+
description="Synchronize calendars and contacts",
53+
license="BSD",
5854
long_description=long_description,
59-
6055
# Runtime dependencies
6156
install_requires=requirements,
62-
6357
# Optional dependencies
6458
extras_require={
65-
'google': ['requests-oauthlib'],
66-
'etesync': ['etesync==0.5.2', 'django<2.0']
59+
"google": ["requests-oauthlib"],
60+
"etesync": ["etesync==0.5.2", "django<2.0"],
6761
},
68-
6962
# Build dependencies
70-
setup_requires=['setuptools_scm != 1.12.0'],
71-
63+
setup_requires=["setuptools_scm != 1.12.0"],
7264
# Other
73-
packages=find_packages(exclude=['tests.*', 'tests']),
65+
packages=find_packages(exclude=["tests.*", "tests"]),
7466
include_package_data=True,
75-
cmdclass={
76-
'minimal_requirements': PrintRequirements
77-
},
78-
use_scm_version={
79-
'write_to': 'vdirsyncer/version.py'
80-
},
81-
entry_points={
82-
'console_scripts': ['vdirsyncer = vdirsyncer.cli:main']
83-
},
67+
cmdclass={"minimal_requirements": PrintRequirements},
68+
use_scm_version={"write_to": "vdirsyncer/version.py"},
69+
entry_points={"console_scripts": ["vdirsyncer = vdirsyncer.cli:main"]},
8470
classifiers=[
85-
'Development Status :: 4 - Beta',
86-
'Environment :: Console',
87-
'License :: OSI Approved :: BSD License',
88-
'Operating System :: POSIX',
89-
'Programming Language :: Python :: 3',
90-
'Programming Language :: Python :: 3.7',
91-
'Programming Language :: Python :: 3.8',
92-
'Programming Language :: Python :: 3.9',
93-
'Topic :: Internet',
94-
'Topic :: Utilities',
71+
"Development Status :: 4 - Beta",
72+
"Environment :: Console",
73+
"License :: OSI Approved :: BSD License",
74+
"Operating System :: POSIX",
75+
"Programming Language :: Python :: 3",
76+
"Programming Language :: Python :: 3.7",
77+
"Programming Language :: Python :: 3.8",
78+
"Programming Language :: Python :: 3.9",
79+
"Topic :: Internet",
80+
"Topic :: Utilities",
9581
],
9682
)

tests/__init__.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
'''
1+
"""
22
Test suite for vdirsyncer.
3-
'''
3+
"""
44
import hypothesis.strategies as st
55
import urllib3.exceptions
66

@@ -10,14 +10,14 @@
1010

1111

1212
def blow_up(*a, **kw):
13-
raise AssertionError('Did not expect to be called.')
13+
raise AssertionError("Did not expect to be called.")
1414

1515

1616
def assert_item_equals(a, b):
1717
assert normalize_item(a) == normalize_item(b)
1818

1919

20-
VCARD_TEMPLATE = '''BEGIN:VCARD
20+
VCARD_TEMPLATE = """BEGIN:VCARD
2121
VERSION:3.0
2222
FN:Cyrus Daboo
2323
N:Daboo;Cyrus;;;
@@ -31,9 +31,9 @@ def assert_item_equals(a, b):
3131
URL;VALUE=URI:http://www.example.com
3232
X-SOMETHING:{r}
3333
UID:{uid}
34-
END:VCARD'''
34+
END:VCARD"""
3535

36-
TASK_TEMPLATE = '''BEGIN:VCALENDAR
36+
TASK_TEMPLATE = """BEGIN:VCALENDAR
3737
VERSION:2.0
3838
PRODID:-//dmfs.org//mimedir.icalendar//EN
3939
BEGIN:VTODO
@@ -45,25 +45,30 @@ def assert_item_equals(a, b):
4545
X-SOMETHING:{r}
4646
UID:{uid}
4747
END:VTODO
48-
END:VCALENDAR'''
48+
END:VCALENDAR"""
4949

5050

51-
BARE_EVENT_TEMPLATE = '''BEGIN:VEVENT
51+
BARE_EVENT_TEMPLATE = """BEGIN:VEVENT
5252
DTSTART:19970714T170000Z
5353
DTEND:19970715T035959Z
5454
SUMMARY:Bastille Day Party
5555
X-SOMETHING:{r}
5656
UID:{uid}
57-
END:VEVENT'''
57+
END:VEVENT"""
5858

5959

60-
EVENT_TEMPLATE = '''BEGIN:VCALENDAR
60+
EVENT_TEMPLATE = (
61+
"""BEGIN:VCALENDAR
6162
VERSION:2.0
6263
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
63-
''' + BARE_EVENT_TEMPLATE + '''
64-
END:VCALENDAR'''
64+
"""
65+
+ BARE_EVENT_TEMPLATE
66+
+ """
67+
END:VCALENDAR"""
68+
)
6569

66-
EVENT_WITH_TIMEZONE_TEMPLATE = '''BEGIN:VCALENDAR
70+
EVENT_WITH_TIMEZONE_TEMPLATE = (
71+
"""BEGIN:VCALENDAR
6772
BEGIN:VTIMEZONE
6873
TZID:Europe/Rome
6974
X-LIC-LOCATION:Europe/Rome
@@ -82,26 +87,23 @@ def assert_item_equals(a, b):
8287
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
8388
END:STANDARD
8489
END:VTIMEZONE
85-
''' + BARE_EVENT_TEMPLATE + '''
86-
END:VCALENDAR'''
90+
"""
91+
+ BARE_EVENT_TEMPLATE
92+
+ """
93+
END:VCALENDAR"""
94+
)
8795

8896

89-
SIMPLE_TEMPLATE = '''BEGIN:FOO
97+
SIMPLE_TEMPLATE = """BEGIN:FOO
9098
UID:{uid}
9199
X-SOMETHING:{r}
92100
HAHA:YES
93-
END:FOO'''
101+
END:FOO"""
94102

95103
printable_characters_strategy = st.text(
96-
st.characters(blacklist_categories=(
97-
'Cc', 'Cs'
98-
))
104+
st.characters(blacklist_categories=("Cc", "Cs"))
99105
)
100106

101107
uid_strategy = st.text(
102-
st.characters(blacklist_categories=(
103-
'Zs', 'Zl', 'Zp',
104-
'Cc', 'Cs'
105-
)),
106-
min_size=1
108+
st.characters(blacklist_categories=("Zs", "Zl", "Zp", "Cc", "Cs")), min_size=1
107109
).filter(lambda x: x.strip() == x)

0 commit comments

Comments
 (0)