Skip to content

Commit

Permalink
Fix some lint violations before enforcing them
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Sep 16, 2023
1 parent 42898bd commit f4deaab
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
17 changes: 8 additions & 9 deletions mkdocs_click/_docs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under the Apache license (see LICENSE)
from __future__ import annotations

import inspect
from contextlib import contextmanager, ExitStack
from typing import Iterator, List, cast, Optional
from contextlib import ExitStack, contextmanager
from typing import Iterator, cast

import click
from markdown.extensions.toc import slugify
Expand Down Expand Up @@ -41,7 +43,7 @@ def make_command_docs(
def _recursively_make_command_docs(
prog_name: str,
command: click.BaseCommand,
parent: click.Context = None,
parent: click.Context | None = None,
depth: int = 0,
style: str = "plain",
remove_ascii_art: bool = False,
Expand Down Expand Up @@ -87,13 +89,11 @@ def _recursively_make_command_docs(
)


def _build_command_context(
prog_name: str, command: click.BaseCommand, parent: Optional[click.Context]
) -> click.Context:
def _build_command_context(prog_name: str, command: click.BaseCommand, parent: click.Context | None) -> click.Context:
return click.Context(cast(click.Command, command), info_name=prog_name, parent=parent)


def _get_sub_commands(command: click.Command, ctx: click.Context) -> List[click.Command]:
def _get_sub_commands(command: click.Command, ctx: click.Context) -> list[click.Command]:
"""Return subcommands of a Click command."""
subcommands = getattr(command, "commands", {})
if subcommands:
Expand Down Expand Up @@ -328,12 +328,11 @@ def _make_table_options(ctx: click.Context, show_hidden: bool = False) -> Iterat


def _make_subcommands_links(
subcommands: List[click.Command],
subcommands: list[click.Command],
parent: click.Context,
has_attr_list: bool,
show_hidden: bool,
) -> Iterator[str]:

yield "**Subcommands**"
yield ""
for command in subcommands:
Expand Down
6 changes: 4 additions & 2 deletions mkdocs_click/_extension.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under the Apache license (see LICENSE)
from typing import Any, Iterator, List
from __future__ import annotations

from typing import Any, Iterator

from markdown.extensions import Extension
from markdown.extensions.attr_list import AttrListExtension
Expand Down Expand Up @@ -48,7 +50,7 @@ def __init__(self, md: Any) -> None:
super().__init__(md)
self._has_attr_list = any(isinstance(ext, AttrListExtension) for ext in md.registeredExtensions)

def run(self, lines: List[str]) -> List[str]:
def run(self, lines: list[str]) -> list[str]:
return list(
replace_blocks(
lines,
Expand Down
3 changes: 3 additions & 0 deletions mkdocs_click/_loader.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under the Apache license (see LICENSE)
from __future__ import annotations

import importlib
from typing import Any

import click

from ._exceptions import MkDocsClickException


Expand Down
4 changes: 3 additions & 1 deletion mkdocs_click/_processing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under the Apache license (see LICENSE)
from __future__ import annotations

import re
from typing import Callable, Iterable, Iterator

Expand Down Expand Up @@ -28,7 +30,7 @@ def replace_blocks(lines: Iterable[str], title: str, replace: Callable[..., Iter
key = match.group("key")
value = match.group("value") or ""
if value.lower() in ["true", "false"]:
value = True if value.lower() == "true" else False
value = value.lower() == "true"
options[key] = value
continue

Expand Down
2 changes: 1 addition & 1 deletion tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import click
import pytest

from mkdocs_click._docs import make_command_docs, _show_options
from mkdocs_click._docs import _show_options, make_command_docs
from mkdocs_click._exceptions import MkDocsClickException


Expand Down

0 comments on commit f4deaab

Please sign in to comment.