Skip to content

MkDevTools

Show source on GitHub

Node showing information about used dev tools.

Example: From project

Jinja

{{ mk.MkDevTools() }}

Python

MkDevTools()

Ruff

Ruff is used as a linter. You can find the configuration in the pyproject.toml file.

hatch run ruff --help
Config
line-length = 90
select = [
    "A",
    "B",
    "BLE",
    "C",
    "C4",
    "COM",
    "D",
    "E",
    "EM",
    "EXE",
    "F",
    "FA",
    "FLY",
    "G",
    "I",
    "ICN",
    "INP",
    "INT",
    "ISC",
    "N",
    "PERF",
    "PIE",
    "PLE",
    "PLC",
    "PLR",
    "PT",
    "PTH",
    "PYI",
    "Q",
    "RET",
    "RSE",
    "RUF",
    "SIM",
    "SLF",
    "SLOT",
    "T10",
    "TID",
    "TRY",
    "UP",
    "W",
    "YTT",
]
ignore = [
    "C408",
    "B905",
    "C901",
    "D100",
    "D101",
    "D102",
    "D103",
    "D104",
    "D105",
    "D106",
    "D107",
    "D203",
    "D204",
    "D213",
    "D215",
    "D400",
    "D401",
    "D404",
    "D406",
    "D407",
    "D408",
    "D409",
    "D413",
    "N813",
    "PLR0912",
    "PLR0913",
    "PLR0915",
    "SLF001",
    "RUF012",
    "TRY003",
    "COM812",
    "COM819",
    "D206",
    "E501",
    "ISC001",
    "Q000",
    "Q001",
    "Q002",
    "Q003",
    "W191",
]
extend-exclude = [
    "docs",
]
target-version = "py311"

[format]
preview = true

[flake8-quotes]
docstring-quotes = "double"

[isort]
lines-after-imports = 2
lines-between-types = 1
force-sort-within-sections = true
combine-as-imports = true

[per-file-ignores]
"__init__.py" = [
    "E402",
    "I001",
]
Installing Ruff

To install ruff:

pip install ruff
More information

Pre-Commit

This project uses pre-commit to ensure code quality. A .pre-commit-config.yaml configuration file tailored for this project is provided in the root folder.

# Setup pre-commit hooks for required formatting
pre-commit install
Config
default_language_version:
    python: python3.11
default_stages: [commit]
repos:
- repo: local
  hooks:
    - id: pytest-check
      name: pytest-check
      entry: hatch run test
      language: system
      # stages: [push]
      types: [python]
      pass_filenames: false
      always_run: true
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v4.5.0
  hooks:
    # - id: trailing-whitespace
    # - id: check-ast
    - id: check-case-conflict
    - id: check-docstring-first
    - id: check-merge-conflict
    # - id: check-yaml
    - id: check-toml
    - id: check-json
    - id: detect-private-key
    - id: forbid-new-submodules
    # - id: check-added-large-files
# https://pre-commit.com/hooks.html
- repo: https://github.com/pre-commit/mirrors-mypy
  rev: v1.7.1
  hooks:
    - id: mypy
      # args: [--ignore-missing-imports]
      additional_dependencies: []

- repo: https://github.com/charliermarsh/ruff-pre-commit
  rev: v0.1.6
  hooks:
    - id: ruff
    - id: ruff-format

- repo: https://github.com/commitizen-tools/commitizen
  rev: 3.12.0
  hooks:
    - id: commitizen
      stages: [commit-msg]
      additional_dependencies: [typing-extensions]
Installing Pre-Commit

To install pre-commit:

pip install pre-commit
More information

Coverage

Coverage is used to monitor test coverage.

hatch run coverage run some_module.py
Config
[report]
exclude_lines = [
    "pragma: no cover",
    "if TYPE_CHECKING:",
    "@overload",
    "except ImportError",
    "if __name__ == \"__main__\":",
]
Installing Coverage

To install coverage:

pip install coverage
More information

MyPy

MyPy is used for type checking. You can find the configuration in the pyproject.toml file.

hatch run mypy --help
Config
python_version = "3.11"
disable_error_code = [
    "assignment",
    "misc",
    "import",
    "has-type",
]
Installing MyPy

To install mypy:

pip install mypy
More information

MkDocs

Ruff is used as a linter. You can find the configuration in the pyproject.toml file.

hatch run ruff --help
Config
line-length = 90
select = [
    "A",
    "B",
    "BLE",
    "C",
    "C4",
    "COM",
    "D",
    "E",
    "EM",
    "EXE",
    "F",
    "FA",
    "FLY",
    "G",
    "I",
    "ICN",
    "INP",
    "INT",
    "ISC",
    "N",
    "PERF",
    "PIE",
    "PLE",
    "PLC",
    "PLR",
    "PT",
    "PTH",
    "PYI",
    "Q",
    "RET",
    "RSE",
    "RUF",
    "SIM",
    "SLF",
    "SLOT",
    "T10",
    "TID",
    "TRY",
    "UP",
    "W",
    "YTT",
]
ignore = [
    "C408",
    "B905",
    "C901",
    "D100",
    "D101",
    "D102",
    "D103",
    "D104",
    "D105",
    "D106",
    "D107",
    "D203",
    "D204",
    "D213",
    "D215",
    "D400",
    "D401",
    "D404",
    "D406",
    "D407",
    "D408",
    "D409",
    "D413",
    "N813",
    "PLR0912",
    "PLR0913",
    "PLR0915",
    "SLF001",
    "RUF012",
    "TRY003",
    "COM812",
    "COM819",
    "D206",
    "E501",
    "ISC001",
    "Q000",
    "Q001",
    "Q002",
    "Q003",
    "W191",
]
extend-exclude = [
    "docs",
]
target-version = "py311"

[format]
preview = true

[flake8-quotes]
docstring-quotes = "double"

[isort]
lines-after-imports = 2
lines-between-types = 1
force-sort-within-sections = true
combine-as-imports = true

[per-file-ignores]
"__init__.py" = [
    "E402",
    "I001",
]
Installing MkDocs

To install mkdocs:

pip install mkdocs
More information

## Ruff

**Ruff** is used as a linter. You can find the configuration in the
`pyproject.toml` file.


```` {.md }
hatch run ruff --help
````

??? quote "Config"
    ```` {.toml }
    line-length = 90
    select = [
        "A",
        "B",
        "BLE",
        "C",
        "C4",
        "COM",
        "D",
        "E",
        "EM",
        "EXE",
        "F",
        "FA",
        "FLY",
        "G",
        "I",
        "ICN",
        "INP",
        "INT",
        "ISC",
        "N",
        "PERF",
        "PIE",
        "PLE",
        "PLC",
        "PLR",
        "PT",
        "PTH",
        "PYI",
        "Q",
        "RET",
        "RSE",
        "RUF",
        "SIM",
        "SLF",
        "SLOT",
        "T10",
        "TID",
        "TRY",
        "UP",
        "W",
        "YTT",
    ]
    ignore = [
        "C408",
        "B905",
        "C901",
        "D100",
        "D101",
        "D102",
        "D103",
        "D104",
        "D105",
        "D106",
        "D107",
        "D203",
        "D204",
        "D213",
        "D215",
        "D400",
        "D401",
        "D404",
        "D406",
        "D407",
        "D408",
        "D409",
        "D413",
        "N813",
        "PLR0912",
        "PLR0913",
        "PLR0915",
        "SLF001",
        "RUF012",
        "TRY003",
        "COM812",
        "COM819",
        "D206",
        "E501",
        "ISC001",
        "Q000",
        "Q001",
        "Q002",
        "Q003",
        "W191",
    ]
    extend-exclude = [
        "docs",
    ]
    target-version = "py311"

    [format]
    preview = true

    [flake8-quotes]
    docstring-quotes = "double"

    [isort]
    lines-after-imports = 2
    lines-between-types = 1
    force-sort-within-sections = true
    combine-as-imports = true

    [per-file-ignores]
    "__init__.py" = [
        "E402",
        "I001",
    ]

    ````


??? info "Installing Ruff"
    To install ruff:
    ```` {.bash }
    pip install ruff
    ````
    [More information](https://beta.ruff.rs/)


## Pre-Commit

This project uses **pre-commit** to ensure code quality.
A `.pre-commit-config.yaml` configuration file tailored for this project is provided
in the root folder.

```` {.md }
# Setup pre-commit hooks for required formatting
pre-commit install
````

??? quote "Config"
    ```` {.yaml }
    default_language_version:
        python: python3.11
    default_stages: [commit]
    repos:
    - repo: local
      hooks:
        - id: pytest-check
          name: pytest-check
          entry: hatch run test
          language: system
          # stages: [push]
          types: [python]
          pass_filenames: false
          always_run: true
    - repo: https://github.com/pre-commit/pre-commit-hooks
      rev: v4.5.0
      hooks:
        # - id: trailing-whitespace
        # - id: check-ast
        - id: check-case-conflict
        - id: check-docstring-first
        - id: check-merge-conflict
        # - id: check-yaml
        - id: check-toml
        - id: check-json
        - id: detect-private-key
        - id: forbid-new-submodules
        # - id: check-added-large-files
    # https://pre-commit.com/hooks.html
    - repo: https://github.com/pre-commit/mirrors-mypy
      rev: v1.7.1
      hooks:
        - id: mypy
          # args: [--ignore-missing-imports]
          additional_dependencies: []

    - repo: https://github.com/charliermarsh/ruff-pre-commit
      rev: v0.1.6
      hooks:
        - id: ruff
        - id: ruff-format

    - repo: https://github.com/commitizen-tools/commitizen
      rev: 3.12.0
      hooks:
        - id: commitizen
          stages: [commit-msg]
          additional_dependencies: [typing-extensions]

    ````


??? info "Installing Pre-Commit"
    To install pre-commit:
    ```` {.bash }
    pip install pre-commit
    ````
    [More information](https://pre-commit.com)


## Coverage

**Coverage** is used to monitor test coverage.

```` {.md }
hatch run coverage run some_module.py
````

??? quote "Config"
    ```` {.toml }
    [report]
    exclude_lines = [
        "pragma: no cover",
        "if TYPE_CHECKING:",
        "@overload",
        "except ImportError",
        "if __name__ == \"__main__\":",
    ]

    ````


??? info "Installing Coverage"
    To install coverage:
    ```` {.bash }
    pip install coverage
    ````
    [More information](https://coverage.readthedocs.io/)


## MyPy

**MyPy** is used for type checking. You can find the configuration in the
`pyproject.toml` file.


```` {.md }
hatch run mypy --help
````

??? quote "Config"
    ```` {.toml }
    python_version = "3.11"
    disable_error_code = [
        "assignment",
        "misc",
        "import",
        "has-type",
    ]

    ````


??? info "Installing MyPy"
    To install mypy:
    ```` {.bash }
    pip install mypy
    ````
    [More information](https://mypy-lang.org)


## MkDocs

**Ruff** is used as a linter. You can find the configuration in the
`pyproject.toml` file.


```` {.md }
hatch run ruff --help
````

??? quote "Config"
    ```` {.toml }
    line-length = 90
    select = [
        "A",
        "B",
        "BLE",
        "C",
        "C4",
        "COM",
        "D",
        "E",
        "EM",
        "EXE",
        "F",
        "FA",
        "FLY",
        "G",
        "I",
        "ICN",
        "INP",
        "INT",
        "ISC",
        "N",
        "PERF",
        "PIE",
        "PLE",
        "PLC",
        "PLR",
        "PT",
        "PTH",
        "PYI",
        "Q",
        "RET",
        "RSE",
        "RUF",
        "SIM",
        "SLF",
        "SLOT",
        "T10",
        "TID",
        "TRY",
        "UP",
        "W",
        "YTT",
    ]
    ignore = [
        "C408",
        "B905",
        "C901",
        "D100",
        "D101",
        "D102",
        "D103",
        "D104",
        "D105",
        "D106",
        "D107",
        "D203",
        "D204",
        "D213",
        "D215",
        "D400",
        "D401",
        "D404",
        "D406",
        "D407",
        "D408",
        "D409",
        "D413",
        "N813",
        "PLR0912",
        "PLR0913",
        "PLR0915",
        "SLF001",
        "RUF012",
        "TRY003",
        "COM812",
        "COM819",
        "D206",
        "E501",
        "ISC001",
        "Q000",
        "Q001",
        "Q002",
        "Q003",
        "W191",
    ]
    extend-exclude = [
        "docs",
    ]
    target-version = "py311"

    [format]
    preview = true

    [flake8-quotes]
    docstring-quotes = "double"

    [isort]
    lines-after-imports = 2
    lines-between-types = 1
    force-sort-within-sections = true
    combine-as-imports = true

    [per-file-ignores]
    "__init__.py" = [
        "E402",
        "I001",
    ]

    ````


??? info "Installing MkDocs"
    To install mkdocs:
    ```` {.bash }
    pip install mkdocs
    ````
    [More information](https://mkdocs.org/)

Bases: MkTemplate

__init__

__init__(tools: list[tools.Tool] | None = None, **kwargs: Any)

Parameters:

Name Type Description Default
tools list[Tool] | None

Tools to show install / setup instructions for. If None, tools will be pulled from project.

None
kwargs Any

Keyword arguments passed to parent

{}
graph TD
  94854583312576["mkdevtools.MkDevTools"]
  94854582782240["mktemplate.MkTemplate"]
  94854582919984["mkcontainer.MkContainer"]
  94854582916880["mknode.MkNode"]
  94854582838576["node.Node"]
  140544995341632["builtins.object"]
  94854582782240 --> 94854583312576
  94854582919984 --> 94854582782240
  94854582916880 --> 94854582919984
  94854582838576 --> 94854582916880
  140544995341632 --> 94854582838576
/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkdevtools/metadata.toml
[metadata]
icon = "mdi:wrench"
status = "new"
name = "MkDevTools"
virtual_children = true

[examples.regular]
title = "From project"
jinja = """
{{ mk.MkDevTools() }}
"""

# [examples.explicit]
# title = "Explicit"
# jinja = """
# {{ ["black"] | MkDevTools }}
# """

[output.markdown]
template = """
{% filter rstrip %}
{% for tool in node.tools %}
{{ tool.title | MkHeader }}

{{ tool.description }}

{% if tool.setup_cmd %}
{{ tool.setup_cmd | render_string | MkCode(language="md")}}

{% endif %}
{{ (tool.cfg.content or "") | MkCode(language=tool.cfg.syntax) | MkAdmonition(collapsible=True, title="Config", typ="quote") }}

{{ ["To install " ~ tool.identifier ~ ":",
    ("pip install " ~ tool.identifier) | MkCode(language="bash"),
    tool.url | MkLink("More information")] | MkAdmonition(collapsible=True, title="Installing " ~ tool.title)}}

{% endfor %}
{% endfilter %}


"""
mknodes.templatenodes.mkdevtools.MkDevTools
class MkDevTools(mktemplate.MkTemplate):
    """Node showing information about used dev tools."""

    ICON = "material/wrench"
    STATUS = "new"
    VIRTUAL_CHILDREN = True

    def __init__(
        self,
        tools: list[tools.Tool] | None = None,
        **kwargs: Any,
    ):
        """Constructor.

        Arguments:
            tools: Tools to show install / setup instructions for.
                            If None, tools will be pulled from project.
            kwargs: Keyword arguments passed to parent
        """
        super().__init__("output/markdown/template", **kwargs)
        self._tools = tools

    @property
    def tools(self) -> list[tools.Tool]:
        match self._tools:
            case list():
                return self._tools
            case None:
                return self.ctx.metadata.tools
            case _:
                raise TypeError(self._tools)