Skip to content

Commit db88664

Browse files
committed
more black
1 parent 06077c8 commit db88664

File tree

4 files changed

+114
-84
lines changed

4 files changed

+114
-84
lines changed

docs/conf.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sphinx_compas_theme
1414
from sphinx.ext.napoleon.docstring import NumpyDocstring
1515

16-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../src'))
16+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../src"))
1717

1818
# -- General configuration ------------------------------------------------
1919

@@ -24,14 +24,14 @@
2424
version = ".".join(release.split(".")[0:2])
2525

2626
master_doc = "index"
27-
source_suffix = [".rst", ]
27+
source_suffix = [".rst"]
2828
templates_path = sphinx_compas_theme.get_autosummary_templates_path()
2929
exclude_patterns = []
3030

31-
pygments_style = "sphinx"
32-
show_authors = True
31+
pygments_style = "sphinx"
32+
show_authors = True
3333
add_module_names = True
34-
language = None
34+
language = None
3535

3636

3737
# -- Extension configuration ------------------------------------------------
@@ -69,7 +69,7 @@
6969
"rhinoscriptsyntax",
7070
"bpy",
7171
"bmesh",
72-
"mathutils"
72+
"mathutils",
7373
]
7474

7575
autodoc_default_options = {
@@ -83,7 +83,7 @@
8383

8484

8585
def skip(app, what, name, obj, would_skip, options):
86-
if name.startswith('_'):
86+
if name.startswith("_"):
8787
return True
8888
return would_skip
8989

@@ -197,13 +197,13 @@ def linkcode_resolve(domain, info):
197197
html_theme_path = sphinx_compas_theme.get_html_theme_path()
198198

199199
html_theme_options = {
200-
"package_name" : "compas_occ",
201-
"package_title" : project,
202-
"package_version" : release,
203-
"package_author" : "compas-dev",
204-
"package_docs" : "https://compas.dev/compas_occ/",
205-
"package_repo" : "https://github.com/compas-dev/compas_occ",
206-
"package_old_versions_txt": "https://compas.dev/compas_occ/doc_versions.txt"
200+
"package_name": "compas_occ",
201+
"package_title": project,
202+
"package_version": release,
203+
"package_author": "compas-dev",
204+
"package_docs": "https://compas.dev/compas_occ/",
205+
"package_repo": "https://github.com/compas-dev/compas_occ",
206+
"package_old_versions_txt": "https://compas.dev/compas_occ/doc_versions.txt",
207207
}
208208

209209
html_context = {}

docs/examples/surface_intersections_with_line.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@
6767
view.add(Collection(intersections), pointsize=30, pointcolor=(0, 0, 1))
6868

6969
for x in intersections:
70-
view.add(Line(base, base + (x - base).scaled(1.2)), linewidth=1, linecolor=(0, 0, 1))
70+
view.add(
71+
Line(base, base + (x - base).scaled(1.2)), linewidth=1, linecolor=(0, 0, 1)
72+
)
7173

7274
view.add(surface.to_mesh(), show_lines=False)
7375

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
def read(*names, **kwargs):
1616
return io.open(
17-
path.join(here, *names),
18-
encoding=kwargs.get("encoding", "utf8")
17+
path.join(here, *names), encoding=kwargs.get("encoding", "utf8")
1918
).read()
2019

2120

tasks.py

Lines changed: 96 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def flush(self):
3131

3232
def write(self, message):
3333
self.flush()
34-
self.out.write(message + '\n')
34+
self.out.write(message + "\n")
3535
self.out.flush()
3636

3737
def info(self, message):
38-
self.write('[INFO] %s' % message)
38+
self.write("[INFO] %s" % message)
3939

4040
def warn(self, message):
41-
self.write('[WARN] %s' % message)
41+
self.write("[WARN] %s" % message)
4242

4343

4444
log = Log()
@@ -48,64 +48,70 @@ def confirm(question):
4848
while True:
4949
response = input(question).lower().strip()
5050

51-
if not response or response in ('n', 'no'):
51+
if not response or response in ("n", "no"):
5252
return False
5353

54-
if response in ('y', 'yes'):
54+
if response in ("y", "yes"):
5555
return True
5656

57-
print('Focus, kid! It is either (y)es or (n)o', file=sys.stderr)
57+
print("Focus, kid! It is either (y)es or (n)o", file=sys.stderr)
5858

5959

6060
@task(default=True)
6161
def help(ctx):
6262
"""Lists available tasks and usage."""
63-
ctx.run('invoke --list')
63+
ctx.run("invoke --list")
6464
log.write('Use "invoke -h <taskname>" to get detailed help for a task.')
6565

6666

67-
@task(help={
68-
'docs': 'True to clean up generated documentation, otherwise False',
69-
'bytecode': 'True to clean up compiled python files, otherwise False.',
70-
'builds': 'True to clean up build/packaging artifacts, otherwise False.'})
67+
@task(
68+
help={
69+
"docs": "True to clean up generated documentation, otherwise False",
70+
"bytecode": "True to clean up compiled python files, otherwise False.",
71+
"builds": "True to clean up build/packaging artifacts, otherwise False.",
72+
}
73+
)
7174
def clean(ctx, docs=True, bytecode=True, builds=True):
7275
"""Cleans the local copy from compiled artifacts."""
7376

7477
with chdir(BASE_FOLDER):
7578
if builds:
76-
ctx.run('python setup.py clean')
79+
ctx.run("python setup.py clean")
7780

7881
if bytecode:
7982
for root, dirs, files in os.walk(BASE_FOLDER):
8083
for f in files:
81-
if f.endswith('.pyc'):
84+
if f.endswith(".pyc"):
8285
os.remove(os.path.join(root, f))
83-
if '.git' in dirs:
84-
dirs.remove('.git')
86+
if ".git" in dirs:
87+
dirs.remove(".git")
8588

8689
folders = []
8790

8891
if docs:
89-
folders.append('docs/api/generated')
92+
folders.append("docs/api/generated")
9093

91-
folders.append('dist/')
94+
folders.append("dist/")
9295

9396
if bytecode:
94-
for t in ('src', 'tests'):
95-
folders.extend(glob.glob('{}/**/__pycache__'.format(t), recursive=True))
97+
for t in ("src", "tests"):
98+
folders.extend(glob.glob("{}/**/__pycache__".format(t), recursive=True))
9699

97100
if builds:
98-
folders.append('build/')
99-
folders.append('src/compas_occ.egg-info/')
101+
folders.append("build/")
102+
folders.append("src/compas_occ.egg-info/")
100103

101104
for folder in folders:
102105
rmtree(os.path.join(BASE_FOLDER, folder), ignore_errors=True)
103106

104107

105-
@task(help={
106-
'rebuild': 'True to clean all previously built docs before starting, otherwise False.',
107-
'doctest': 'True to run doctests, otherwise False.',
108-
'check_links': 'True to check all web links in docs for validity, otherwise False.'})
108+
@task(
109+
help={
110+
"rebuild": "True to clean all previously built docs before starting, otherwise False.",
111+
"doctest": "True to run doctests, otherwise False.",
112+
"check_links": "True to check all web links in docs for validity, otherwise False.",
113+
}
114+
)
109115
def docs(ctx, doctest=False, rebuild=False, check_links=False):
110116
"""Builds package's HTML documentation."""
111117

@@ -116,8 +122,8 @@ def docs(ctx, doctest=False, rebuild=False, check_links=False):
116122
if doctest:
117123
testdocs(ctx)
118124

119-
opts = '-E' if rebuild else ''
120-
ctx.run('sphinx-build {} -b html docs dist/docs'.format(opts))
125+
opts = "-E" if rebuild else ""
126+
ctx.run("sphinx-build {} -b html docs dist/docs".format(opts))
121127

122128
if check_links:
123129
linkcheck(ctx, rebuild=rebuild)
@@ -126,23 +132,23 @@ def docs(ctx, doctest=False, rebuild=False, check_links=False):
126132
@task()
127133
def lint(ctx):
128134
"""Check the consistency of coding style."""
129-
log.write('Running flake8 python linter...')
130-
ctx.run('flake8 src')
135+
log.write("Running flake8 python linter...")
136+
ctx.run("flake8 src")
131137

132138

133139
@task()
134140
def testdocs(ctx):
135141
"""Test the examples in the docstrings."""
136-
log.write('Running doctest...')
137-
ctx.run('pytest --doctest-modules')
142+
log.write("Running doctest...")
143+
ctx.run("pytest --doctest-modules")
138144

139145

140146
@task()
141147
def linkcheck(ctx, rebuild=False):
142148
"""Check links in documentation."""
143-
log.write('Running link check...')
144-
opts = '-E' if rebuild else ''
145-
ctx.run('sphinx-build {} -b linkcheck docs dist/docs'.format(opts))
149+
log.write("Running link check...")
150+
opts = "-E" if rebuild else ""
151+
ctx.run("sphinx-build {} -b linkcheck docs dist/docs".format(opts))
146152

147153

148154
@task()
@@ -152,79 +158,102 @@ def check(ctx):
152158
with chdir(BASE_FOLDER):
153159
lint(ctx)
154160

155-
log.write('Checking MANIFEST.in...')
156-
ctx.run('check-manifest')
161+
log.write("Checking MANIFEST.in...")
162+
ctx.run("check-manifest")
157163

158-
log.write('Checking metadata...')
159-
ctx.run('python setup.py check --strict --metadata')
164+
log.write("Checking metadata...")
165+
ctx.run("python setup.py check --strict --metadata")
160166

161167

162-
@task(help={
163-
'checks': 'True to run all checks before testing, otherwise False.'})
168+
@task(help={"checks": "True to run all checks before testing, otherwise False."})
164169
def test(ctx, checks=False, doctest=False):
165170
"""Run all tests."""
166171
if checks:
167172
check(ctx)
168173

169174
with chdir(BASE_FOLDER):
170-
cmd = ['pytest']
175+
cmd = ["pytest"]
171176
if doctest:
172-
cmd.append('--doctest-modules')
177+
cmd.append("--doctest-modules")
173178

174-
ctx.run(' '.join(cmd))
179+
ctx.run(" ".join(cmd))
175180

176181

177182
@task
178183
def prepare_changelog(ctx):
179184
"""Prepare changelog for next release."""
180-
UNRELEASED_CHANGELOG_TEMPLATE = '## Unreleased\n\n### Added\n\n### Changed\n\n### Removed\n\n\n## '
185+
UNRELEASED_CHANGELOG_TEMPLATE = (
186+
"## Unreleased\n\n### Added\n\n### Changed\n\n### Removed\n\n\n## "
187+
)
181188

182189
with chdir(BASE_FOLDER):
183190
# Preparing changelog for next release
184-
with open('CHANGELOG.md', 'r+') as changelog:
191+
with open("CHANGELOG.md", "r+") as changelog:
185192
content = changelog.read()
186193
changelog.seek(0)
187-
changelog.write(content.replace(
188-
'## ', UNRELEASED_CHANGELOG_TEMPLATE, 1))
194+
changelog.write(content.replace("## ", UNRELEASED_CHANGELOG_TEMPLATE, 1))
189195

190-
ctx.run('git add CHANGELOG.md && git commit -m "Prepare changelog for next release"')
196+
ctx.run(
197+
'git add CHANGELOG.md && git commit -m "Prepare changelog for next release"'
198+
)
191199

192200

193-
@task(help={
194-
'gh_io_folder': 'Folder where GH_IO.dll is located. Defaults to the Rhino 6.0 installation folder (platform-specific).',
195-
'ironpython': 'Command for running the IronPython executable. Defaults to `ipy`.'})
201+
@task(
202+
help={
203+
"gh_io_folder": "Folder where GH_IO.dll is located. Defaults to the Rhino 6.0 installation folder (platform-specific).",
204+
"ironpython": "Command for running the IronPython executable. Defaults to `ipy`.",
205+
}
206+
)
196207
def build_ghuser_components(ctx, gh_io_folder=None, ironpython=None):
197208
"""Build Grasshopper user objects from source"""
198209
with chdir(BASE_FOLDER):
199-
with tempfile.TemporaryDirectory('actions.ghcomponentizer') as action_dir:
200-
target_dir = source_dir = os.path.abspath('src/compas_ghpython/components')
201-
ctx.run('git clone https://github.com/compas-dev/compas-actions.ghpython_components.git {}'.format(action_dir))
210+
with tempfile.TemporaryDirectory("actions.ghcomponentizer") as action_dir:
211+
target_dir = source_dir = os.path.abspath("src/compas_ghpython/components")
212+
ctx.run(
213+
"git clone https://github.com/compas-dev/compas-actions.ghpython_components.git {}".format(
214+
action_dir
215+
)
216+
)
202217

203218
if not gh_io_folder:
204219
import compas_ghpython
205-
gh_io_folder = compas_ghpython.get_grasshopper_plugin_path('6.0')
220+
221+
gh_io_folder = compas_ghpython.get_grasshopper_plugin_path("6.0")
206222

207223
if not ironpython:
208-
ironpython = 'ipy'
224+
ironpython = "ipy"
209225

210226
gh_io_folder = os.path.abspath(gh_io_folder)
211-
componentizer_script = os.path.join(action_dir, 'componentize.py')
212-
213-
ctx.run('{} {} {} {} --ghio "{}"'.format(ironpython, componentizer_script, source_dir, target_dir, gh_io_folder))
214-
215-
216-
@task(help={
217-
'release_type': 'Type of release follows semver rules. Must be one of: major, minor, patch.'})
227+
componentizer_script = os.path.join(action_dir, "componentize.py")
228+
229+
ctx.run(
230+
'{} {} {} {} --ghio "{}"'.format(
231+
ironpython,
232+
componentizer_script,
233+
source_dir,
234+
target_dir,
235+
gh_io_folder,
236+
)
237+
)
238+
239+
240+
@task(
241+
help={
242+
"release_type": "Type of release follows semver rules. Must be one of: major, minor, patch."
243+
}
244+
)
218245
def release(ctx, release_type):
219246
"""Releases the project in one swift command!"""
220-
if release_type not in ('patch', 'minor', 'major'):
221-
raise Exit('The release type parameter is invalid.\nMust be one of: major, minor, patch.')
247+
if release_type not in ("patch", "minor", "major"):
248+
raise Exit(
249+
"The release type parameter is invalid.\nMust be one of: major, minor, patch."
250+
)
222251

223252
# Run checks
224-
ctx.run('invoke check test')
253+
ctx.run("invoke check test")
225254

226255
# Bump version and git tag it
227-
ctx.run('bump2version %s --verbose' % release_type)
256+
ctx.run("bump2version %s --verbose" % release_type)
228257

229258
# Prepare the change log for the next release
230259
prepare_changelog(ctx)

0 commit comments

Comments
 (0)