From 42670f416012d789abc27378ed066e7fb4426fce Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 03:22:49 +0200 Subject: [PATCH] MAINT: address Ruff issues --- docs/conf.py | 10 +++++----- pyproject.toml | 1 + src/pwa_pages/repo/_gitlab.py | 2 +- tests/test_project_inventory.py | 9 +++------ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b4b6606a..2f4548cd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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() @@ -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, @@ -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")) @@ -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 = [ diff --git a/pyproject.toml b/pyproject.toml index 68175eba..fe0d9476 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -188,6 +188,7 @@ task-tags = ["cspell"] "docs/*" = [ "E402", "INP001", + "PLW2901", "S101", "S113", "T201", diff --git a/src/pwa_pages/repo/_gitlab.py b/src/pwa_pages/repo/_gitlab.py index c5e1cbbe..136a00e4 100644 --- a/src/pwa_pages/repo/_gitlab.py +++ b/src/pwa_pages/repo/_gitlab.py @@ -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"]) diff --git a/tests/test_project_inventory.py b/tests/test_project_inventory.py index 57c9983b..07790346 100644 --- a/tests/test_project_inventory.py +++ b/tests/test_project_inventory.py @@ -90,9 +90,7 @@ def test_create_project_entry(): ) assert ( _create_project_entry(project) - == 'name' - + '
  • sub1' - + '
  • sub2' + == 'name
  • sub1
  • sub2' ) @@ -114,9 +112,8 @@ def test_to_html_table(project_inventory, fetch, fix_alignment): src = fix_html_alignment(src) if fetch: assert '2020' in src - else: - if fetch: - assert '2020' in src + elif fetch: + assert '2020' in src # cspell: ignore thead assert src.startswith("") assert src.count("") == 1