Skip to content

Commit

Permalink
MAINT: address Ruff issues
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Jul 7, 2023
1 parent ae853f5 commit 42670f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
10 changes: 5 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def get_version(package_name: str) -> str:
if not line:
continue
line_segments = tuple(line.split("=="))
if len(line_segments) != 2:
if len(line_segments) != 2: # noqa: PLR2004
continue
_, installed_version, *_ = line_segments
installed_version = installed_version.strip()
Expand Down Expand Up @@ -328,7 +328,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:


def wikilink(pattern: str) -> RoleFunction:
def role(
def role( # noqa: PLR0913
name: str,
rawtext: str,
text: str,
Expand Down Expand Up @@ -372,9 +372,9 @@ def et_al(children, data, sep="", sep2=None, last_sep=None): # type: ignore[no-
parts = [part for part in _format_list(children, data) if part]
if len(parts) <= 1:
return Text(*parts)
if len(parts) == 2:
if len(parts) == 2: # noqa: PLR2004
return Text(sep2).join(parts)
if len(parts) == 3:
if len(parts) == 3: # noqa: PLR2004
return Text(last_sep).join([Text(sep).join(parts[:-1]), parts[-1]])
return Text(parts[0], Tag("em", " et al"))

Expand All @@ -386,7 +386,7 @@ def names(children, context, role, **kwargs): # type: ignore[no-untyped-def]
try:
persons = context["entry"].persons[role]
except KeyError:
raise FieldIsMissing(role, context["entry"])
raise FieldIsMissing(role, context["entry"]) from None

style = context["style"]
formatted_names = [
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ task-tags = ["cspell"]
"docs/*" = [
"E402",
"INP001",
"PLW2901",
"S101",
"S113",
"T201",
Expand Down
2 changes: 1 addition & 1 deletion src/pwa_pages/repo/_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def split_gitlab_repo_url(url: str) -> Optional[Tuple[str, str]]:
def get_first_commit_date(repo: GitlabProject) -> datetime:
commits: ProjectCommitManager = repo.commits
all_commits = commits.list(all=True)
assert isinstance(all_commits, list)
assert isinstance(all_commits, list) # noqa: S101
first_commit = all_commits[-1]
commit_info = first_commit._attrs
return parse_date(commit_info["created_at"])
Expand Down
9 changes: 3 additions & 6 deletions tests/test_project_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ def test_create_project_entry():
)
assert (
_create_project_entry(project)
== '<a href="url">name</a>'
+ '<li><a href="url">sub1</a>'
+ '<li><a href="url">sub2</a>'
== '<a href="url">name</a><li><a href="url">sub1</a><li><a href="url">sub2</a>'
)


Expand All @@ -114,9 +112,8 @@ def test_to_html_table(project_inventory, fetch, fix_alignment):
src = fix_html_alignment(src)
if fetch:
assert '<td style="text-align:center; vertical-align:top">2020</td>' in src
else:
if fetch:
assert '<td align="right">2020</td>' in src
elif fetch:
assert '<td align="right">2020</td>' in src
# cspell: ignore thead
assert src.startswith("<table>")
assert src.count("<thead>") == 1
Expand Down

0 comments on commit 42670f4

Please sign in to comment.