Skip to content

Commit 31d5916

Browse files
committed
pre-commit
1 parent 29bb490 commit 31d5916

27 files changed

+85
-184
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010

11-
lint:
11+
lint:
1212
# could be re-implemented if desired
1313
if: false
1414
runs-on: ubuntu-latest
@@ -55,7 +55,7 @@ jobs:
5555

5656
- name: Run mypy
5757
run: tox -e typing
58-
58+
5959
test:
6060
runs-on: ubuntu-latest
6161

astropylibrarian/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__all__ = ("__version__",)
77

88
try:
9-
from ._version import __version__
9+
from ._version import __version__
1010
except ImportError:
1111
# package is not installed
1212
__version__ = ""

astropylibrarian/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
"""This module enables running the CLI as::
33
4-
python -m astropylibrarian
4+
python -m astropylibrarian
55
"""
66

77
from astropylibrarian.cli.app import app

astropylibrarian/algolia/records.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ class AlgoliaRecord(BaseModel):
5555
)
5656

5757
root_summary: Optional[str] = Field(
58-
description=(
59-
"Short summary of the content corresponding to the root_url."
60-
)
58+
description=("Short summary of the content corresponding to the root_url.")
6159
)
6260

6361
content_type: ContentType = Field(description="Content type.")
@@ -87,8 +85,7 @@ class AlgoliaRecord(BaseModel):
8785

8886
base_url: HttpUrl = Field(
8987
description=(
90-
"The base URL of the page, without fragments, parameters, "
91-
"queries, etc."
88+
"The base URL of the page, without fragments, parameters, queries, etc."
9289
),
9390
)
9491

@@ -140,9 +137,7 @@ def compute_object_id_for_section(section: Section) -> str:
140137
str
141138
The ``objectID`` for an Algolia record.
142139
"""
143-
url_component = b64encode(section.url.lower().encode("utf-8")).decode(
144-
"utf-8"
145-
)
140+
url_component = b64encode(section.url.lower().encode("utf-8")).decode("utf-8")
146141
heading_component = b64encode(
147142
" ".join(section.headings).encode("utf-8")
148143
).decode("utf-8")
@@ -235,9 +230,7 @@ class TutorialRecord(AlgoliaRecord):
235230
description="List of python package keywords.",
236231
)
237232

238-
task_keywords: Optional[List[str]] = Field(
239-
description="List of task keywords."
240-
)
233+
task_keywords: Optional[List[str]] = Field(description="List of task keywords.")
241234

242235
science_keywords: Optional[List[str]] = Field(
243236
description="List of science keywords."
@@ -307,16 +300,12 @@ def from_section(
307300
"python_package_keywords": keyworddb.filter_keywords(
308301
tutorial.keywords, "python_package"
309302
),
310-
"task_keywords": keyworddb.filter_keywords(
311-
tutorial.keywords, "task"
312-
),
313-
"science_keywords": keyworddb.filter_keywords(
314-
tutorial.keywords, "science"
315-
),
303+
"task_keywords": keyworddb.filter_keywords(tutorial.keywords, "task"),
304+
"science_keywords": keyworddb.filter_keywords(tutorial.keywords, "science"),
316305
"priority": priority,
317306
}
318307
for i, heading in enumerate(section.headings):
319-
kwargs[f"h{i+1}"] = heading
308+
kwargs[f"h{i + 1}"] = heading
320309
if tutorial.images:
321310
# TODO consider an explicitly set thumbnail from tutorial metadata
322311
kwargs["thumbnail_url"] = tutorial.images[0]
@@ -372,9 +361,7 @@ def from_section(
372361
# The importance of 1 is reserved for the homepage URL so that the
373362
# homepage is featured in default listings. All other records have
374363
# importance bumped down lower.
375-
if (page.url == site_metadata.homepage_url) and (
376-
section.header_level == 1
377-
):
364+
if (page.url == site_metadata.homepage_url) and (section.header_level == 1):
378365
importance = 1
379366
else:
380367
importance = section.header_level + 1
@@ -393,5 +380,5 @@ def from_section(
393380
"priority": site_metadata.priority,
394381
}
395382
for i, heading in enumerate(section.headings):
396-
kwargs[f"h{i+1}"] = heading
383+
kwargs[f"h{i + 1}"] = heading
397384
return cls(**kwargs)

astropylibrarian/cli/app.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
from astropylibrarian.cli import index
1313
from astropylibrarian.workflows.deleterooturl import delete_root_url
1414

15-
app = typer.Typer(
16-
short_help="Manage the content indexed by the Learn Astropy project."
17-
)
15+
app = typer.Typer(short_help="Manage the content indexed by the Learn Astropy project.")
1816
app.add_typer(index.app, name="index")
1917

2018

@@ -29,7 +27,7 @@ def main_callback(
2927
"Verbose output. Use -v for info-type logging and -vv for "
3028
"debug-level logging."
3129
),
32-
)
30+
),
3331
) -> None:
3432
"""Manage the content index for the Learn Astropy project.
3533
@@ -49,16 +47,12 @@ def main_callback(
4947

5048
if logging_level == logging.DEBUG:
5149
# Include the module name in the logging for easier debugging
52-
log_format = (
53-
"%(asctime)s %(levelname)8s %(name)s:%(lineno)d | %(message)s"
54-
)
50+
log_format = "%(asctime)s %(levelname)8s %(name)s:%(lineno)d | %(message)s"
5551
else:
5652
log_format = "%(levelname)s: %(message)s"
5753

5854
handler = logging.StreamHandler()
59-
handler.setFormatter(
60-
logging.Formatter(log_format, datefmt="%Y-%m-%d:%H:%M:%S")
61-
)
55+
handler.setFormatter(logging.Formatter(log_format, datefmt="%Y-%m-%d:%H:%M:%S"))
6256
logger = logging.getLogger("astropylibrarian")
6357
logger.addHandler(handler)
6458
logger.setLevel(logging_level)
@@ -67,9 +61,7 @@ def main_callback(
6761
@app.command()
6862
def delete(
6963
url: str = typer.Argument(..., help="Root URL to delete"),
70-
algolia_id: str = typer.Option(
71-
..., help="Algolia app ID.", envvar="ALGOLIA_ID"
72-
),
64+
algolia_id: str = typer.Option(..., help="Algolia app ID.", envvar="ALGOLIA_ID"),
7365
algolia_key: str = typer.Option(
7466
...,
7567
help="Algolia API key.",

astropylibrarian/cli/index.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
@app.command()
2424
def tutorial(
2525
url: str = typer.Argument(..., help="URL or path for a tutorial."),
26-
algolia_id: str = typer.Option(
27-
..., help="Algolia app ID.", envvar="ALGOLIA_ID"
28-
),
26+
algolia_id: str = typer.Option(..., help="Algolia app ID.", envvar="ALGOLIA_ID"),
2927
algolia_key: str = typer.Option(
3028
...,
3129
help="Algolia API key.",
@@ -61,13 +59,9 @@ def tutorial(
6159

6260
@app.command("tutorial-site")
6361
def tutorial_site(
64-
site_dir: Path = typer.Argument(
65-
..., help="Local path tutorial build directory"
66-
),
62+
site_dir: Path = typer.Argument(..., help="Local path tutorial build directory"),
6763
url: str = typer.Argument(..., help="Base URL for tutorials."),
68-
algolia_id: str = typer.Option(
69-
..., help="Algolia app ID.", envvar="ALGOLIA_ID"
70-
),
64+
algolia_id: str = typer.Option(..., help="Algolia app ID.", envvar="ALGOLIA_ID"),
7165
algolia_key: str = typer.Option(
7266
...,
7367
help="Algolia API key.",
@@ -179,9 +173,7 @@ async def run_index_tutorial(
179173
@app.command()
180174
def guide(
181175
url: str = typer.Argument(..., help="Root URL for a guide."),
182-
algolia_id: str = typer.Option(
183-
..., help="Algolia app ID.", envvar="ALGOLIA_ID"
184-
),
176+
algolia_id: str = typer.Option(..., help="Algolia app ID.", envvar="ALGOLIA_ID"),
185177
algolia_key: str = typer.Option(
186178
...,
187179
help="Algolia API key.",

astropylibrarian/keywords.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,13 @@ def load(cls, path: Optional[Path] = None) -> "KeywordDb":
5454

5555
keyword_groups: Dict[str, KeywordTable] = {}
5656
for group_name in db:
57-
keyword_groups[group_name] = cls._load_keyword_table(
58-
db[group_name]
59-
)
57+
keyword_groups[group_name] = cls._load_keyword_table(db[group_name])
6058

6159
return cls(**keyword_groups)
6260

6361
@staticmethod
6462
def _load_keyword_table(
65-
group: Sequence[Union[str, Dict[str, Sequence[str]]]]
63+
group: Sequence[Union[str, Dict[str, Sequence[str]]]],
6664
) -> KeywordTable:
6765
keywords: KeywordTable = {}
6866
for keyword_item in group:

astropylibrarian/reducers/jupyterbook.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ class JupyterBookMetadata(BaseModel):
224224
def all_page_urls(self) -> List[str]:
225225
"""The ``page_urls`` along with the ``homepage_url``."""
226226
return list(
227-
set(
228-
[str(url) for url in self.page_urls] + [str(self.homepage_url)]
229-
)
227+
set([str(url) for url in self.page_urls] + [str(self.homepage_url)])
230228
)
231229

232230
@validator("root_url")

astropylibrarian/reducers/tutorial.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ def iter_algolia_objects(
154154
An object compatible with algolia search ``save_objects``-type
155155
methods.
156156
"""
157-
for record in self.iter_records(
158-
index_epoch=index_epoch, priority=priority
159-
):
157+
for record in self.iter_records(index_epoch=index_epoch, priority=priority):
160158
yield from record.export_capped_records_to_algolia()
161159

162160
def _set_summary_on_h1_section(self) -> None:
@@ -186,9 +184,7 @@ def process_html(self, html_page: HtmlPage) -> None:
186184
pass
187185

188186
try:
189-
authors_paragraph = doc.cssselect(
190-
".card section p, .card .section p"
191-
)[0]
187+
authors_paragraph = doc.cssselect(".card section p, .card .section p")[0]
192188
self._authors = self._parse_comma_list(authors_paragraph)
193189
except IndexError:
194190
pass
@@ -254,9 +250,7 @@ def process_html(self, html_page: HtmlPage) -> None:
254250
doc = html_page.parse()
255251

256252
try:
257-
self._h1 = (
258-
doc.cssselect("h1")[0].text_content().rstrip("¶").strip()
259-
)
253+
self._h1 = doc.cssselect("h1")[0].text_content().rstrip("¶").strip()
260254
except IndexError:
261255
logger.warning("Did not find h1")
262256
pass

astropylibrarian/reducers/utils.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2-
"""Utilities for reducing HTML pages into search records.
3-
"""
2+
"""Utilities for reducing HTML pages into search records."""
43

54
from __future__ import annotations
65

@@ -145,9 +144,7 @@ def iter_sphinx_sections(
145144
logger.debug("Could not get content from %s", content_element)
146145
continue
147146

148-
yield Section(
149-
content="\n\n".join(text_elements), headings=current_headers, url=url
150-
)
147+
yield Section(content="\n\n".join(text_elements), headings=current_headers, url=url)
151148

152149

153150
def iter_nbcollection_sections(
@@ -204,9 +201,7 @@ def iter_nbcollection_sections(
204201
if "id" in content_element.attrib.keys():
205202
header_id = content_element.attrib["id"]
206203
if header_callback:
207-
header_content = header_callback(
208-
content_element.text_content()
209-
)
204+
header_content = header_callback(content_element.text_content())
210205
else:
211206
header_content = content_element.text_content()
212207
logger.debug("Got header %s\n", header_content)

0 commit comments

Comments
 (0)