Skip to content

Commit 60b7f8d

Browse files
authored
Small formatting fixes (#120)
* remove noqa; rebuild docs * add black check * rerun used updated black
1 parent 5ee9912 commit 60b7f8d

File tree

6 files changed

+43
-45
lines changed

6 files changed

+43
-45
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ test: lint
2828
pytest -vv
2929

3030
lint:
31+
black --check deon tests docs
3132
flake8 .
3233

3334
## Run tests and build rendered examples and docs

deon/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .cli import main
22

33
if __name__ == "__main__":
4-
main(prog_name='python -m deon')
4+
main(prog_name="python -m deon")

deon/formats.py

+30-34
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
# File types
88
class Format(object):
9-
""" Template for a specific file type; renders and
10-
writes out to file.
9+
"""Template for a specific file type; renders and
10+
writes out to file.
1111
12-
For text formats, simply override the templates
13-
below. For other formats, override `render`
14-
and `write`.
12+
For text formats, simply override the templates
13+
below. For other formats, override `render`
14+
and `write`.
1515
16-
`render` should return an object whose string
17-
representation is a fully valid document of
18-
that format.
16+
`render` should return an object whose string
17+
representation is a fully valid document of
18+
that format.
1919
"""
2020

2121
template = "{title}\n\n{sections}\n\n{docs_link}"
@@ -33,8 +33,8 @@ def __init__(self, checklist):
3333
self.checklist = checklist
3434

3535
def render(self):
36-
""" Uses the checklist and templates to render
37-
all of the components for this format.
36+
"""Uses the checklist and templates to render
37+
all of the components for this format.
3838
"""
3939
rendered_sections = []
4040
for section in self.checklist.sections:
@@ -60,14 +60,14 @@ def render(self):
6060
sections=all_sections,
6161
docs_link=self.docs_link,
6262
badge=self.badge,
63-
) # noqa: E501
63+
)
6464

6565
def write(self, filepath, overwrite=False):
66-
""" Renders template and writes to `filepath`.
66+
"""Renders template and writes to `filepath`.
6767
68-
If `overwrite=True`, write over anything at
69-
`filepath`. Else, if the file exists append to
70-
the end of file.
68+
If `overwrite=True`, write over anything at
69+
`filepath`. Else, if the file exists append to
70+
the end of file.
7171
"""
7272
filepath = Path(filepath)
7373

@@ -82,8 +82,7 @@ def write(self, filepath, overwrite=False):
8282

8383

8484
class Markdown(Format):
85-
""" Markdown template items
86-
"""
85+
"""Markdown template items"""
8786

8887
template = "# {title}\n{badge}\n{sections}\n\n{docs_link}"
8988
section_template = """## {title}
@@ -95,12 +94,11 @@ class Markdown(Format):
9594
)
9695
badge = """
9796
[![Deon badge](https://img.shields.io/badge/ethics%20checklist-deon-brightgreen.svg?style=popout-square)](http://deon.drivendata.org/)
98-
""" # noqa: E501
97+
"""
9998

10099

101100
class Rst(Format):
102-
"""reStructuredText template items
103-
"""
101+
"""reStructuredText template items"""
104102

105103
template = "{title}\n============\n\n{badge}\n\n{sections}\n\n{docs_link}"
106104
section_template = """{title}\n---------\n\n{lines}"""
@@ -123,14 +121,13 @@ def __repr__(self):
123121

124122

125123
class JupyterNotebook(Markdown):
126-
""" Jupyter notebook template items
127-
"""
124+
"""Jupyter notebook template items"""
128125

129126
append_delimiter = {"cell_type": "markdown", "metadata": {}, "source": ["-----\n"]}
130127

131128
def render(self):
132-
""" Creates json for a valid blank Jupyter notebook with a cell
133-
containing the rendered Markdown of the checklist.
129+
"""Creates json for a valid blank Jupyter notebook with a cell
130+
containing the rendered Markdown of the checklist.
134131
"""
135132
text = super().render()
136133

@@ -150,9 +147,9 @@ def render(self):
150147
return JsonDict(blank_jupyter_notebook)
151148

152149
def write(self, filepath, overwrite=False):
153-
""" If notebook does not exist (or `overwrite=True`), write new
154-
notebook with checklist. Otherwise append a cell with a
155-
horizontal rule and another cell with the checklist.
150+
"""If notebook does not exist (or `overwrite=True`), write new
151+
notebook with checklist. Otherwise append a cell with a
152+
horizontal rule and another cell with the checklist.
156153
"""
157154
nbdata = self.render()
158155

@@ -171,8 +168,7 @@ def write(self, filepath, overwrite=False):
171168

172169

173170
class JupyterNotebookMulticell(JupyterNotebook):
174-
""" Jupyter notebook multiple cell format
175-
"""
171+
"""Jupyter notebook multiple cell format"""
176172

177173
def render(self):
178174
text = super(JupyterNotebook, self).render()
@@ -232,18 +228,18 @@ class Html(Format):
232228
"""
233229

234230
def render(self):
235-
""" Create a new blank HTML document with checklist as the body.
236-
Returned as a BeautifulSoup object.
231+
"""Create a new blank HTML document with checklist as the body.
232+
Returned as a BeautifulSoup object.
237233
"""
238234
rendered_html = self.doc_template.format(text=super().render())
239235
soup = BeautifulSoup(rendered_html, "html.parser")
240236
# string representation of soup is the raw html, so we can return it
241237
return soup
242238

243239
def write(self, filepath, overwrite=False):
244-
""" If html document does not exist (or `overwrite=True`), write new
245-
html file with checklist. Otherwise append checklist to the end of
246-
the body of the existing html file.
240+
"""If html document does not exist (or `overwrite=True`), write new
241+
html file with checklist. Otherwise append checklist to the end of
242+
the body of the existing html file.
247243
"""
248244
filepath = Path(filepath)
249245

deon/parser.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33

44
class Checklist(object):
5-
""" Stores a checklist data parsed from a yaml file.
6-
"""
5+
"""Stores a checklist data parsed from a yaml file."""
76

87
def __init__(self, title, sections):
98
self.title = title
@@ -27,8 +26,8 @@ def read(cls, filepath):
2726

2827

2928
class Section(object):
30-
""" Stores the sections of the checklist that are read in
31-
from a file.
29+
"""Stores the sections of the checklist that are read in
30+
from a file.
3231
"""
3332

3433
def __init__(self, title, section_id, lines):

docs/render_templates.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
from deon.parser import Checklist
1111

1212

13-
env = Environment(loader=FileSystemLoader("md_templates"),)
13+
env = Environment(
14+
loader=FileSystemLoader("md_templates"),
15+
)
1416

1517
TEMPLATE_AND_OUTPUT = {
1618
"index.tpl": Path("docs/index.md"),

tests/assets.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
- [ ] **B.1 B1sum**: First B line
2525
- [ ] **B.2 B2sum**: Second B line
2626
27-
*Data Science Ethics Checklist generated with [deon](http://deon.drivendata.org).*""" # noqa: E501
27+
*Data Science Ethics Checklist generated with [deon](http://deon.drivendata.org).*"""
2828

2929
known_good_rst = """My Checklist
3030
============
@@ -57,7 +57,7 @@
5757
"source": [
5858
"# My Checklist\n",
5959
"\n",
60-
"[![Deon badge](https://img.shields.io/badge/ethics%20checklist-deon-brightgreen.svg?style=popout-square)](http://deon.drivendata.org/)\n", # noqa: E501
60+
"[![Deon badge](https://img.shields.io/badge/ethics%20checklist-deon-brightgreen.svg?style=popout-square)](http://deon.drivendata.org/)\n",
6161
"\n",
6262
"## A. First section\n",
6363
" - [ ] **A.1 A1sum**: First A line\n",
@@ -84,7 +84,7 @@
8484
"cell_type": "markdown",
8585
"metadata": {},
8686
"source": [
87-
"[![Deon badge](https://img.shields.io/badge/ethics%20checklist-deon-brightgreen.svg?style=popout-square)](http://deon.drivendata.org/)", # noqa: E501
87+
"[![Deon badge](https://img.shields.io/badge/ethics%20checklist-deon-brightgreen.svg?style=popout-square)](http://deon.drivendata.org/)",
8888
],
8989
},
9090
{"cell_type": "markdown", "metadata": {}, "source": ["## A. First section"]},
@@ -182,7 +182,7 @@
182182
</em>
183183
</body>
184184
</html>
185-
""" # noqa: E501
185+
"""
186186

187187
existing_text_html = """<html>
188188
<body>
@@ -255,4 +255,4 @@
255255
</em>
256256
</body>
257257
</html>
258-
""" # noqa: E501
258+
"""

0 commit comments

Comments
 (0)