Skip to content

Dev Tools

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.12
default_stages: [pre-commit]
repos:
    - repo: local
      hooks:
          - id: pytest-check
            name: pytest-check
            entry: uv run pytest
            language: system
            # stages: [push]
            types: [python]
            pass_filenames: false
            always_run: true
    - repo: https://github.com/pre-commit/pre-commit-hooks
      rev: v5.0.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.13.0
      hooks:
          - id: mypy
            # args: [--ignore-missing-imports]
            additional_dependencies: [mkdocs, orjson, pydantic]

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

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

To install pre-commit:

pip install pre-commit
More information

PyRight

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

hatch run pyright --help
Config
pythonVersion = "3.12"
pythonPlatform = "All"
deprecateTypingAliases = true
reportUnusedCallResult = false
reportUnknownVariableType = false
reportImplicitOverride = false
reportAny = false
reportUnannotatedClassAttribute = false
Installing PyRight

To install pyright:

pip install pyright
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
extend-exclude = [
    "docs",
]
target-version = "py312"

[lint]
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",
    "COM812",
    "D100",
    "D101",
    "D102",
    "D103",
    "D104",
    "D105",
    "D106",
    "D107",
    "D203",
    "D204",
    "D213",
    "D215",
    "D400",
    "D401",
    "D404",
    "D406",
    "D407",
    "D408",
    "D409",
    "D413",
    "ISC001",
    "PLR0912",
    "PLR0913",
    "PLR0915",
    "SLF001",
    "TRY003",
]

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

[lint.isort]
lines-after-imports = 2
force-sort-within-sections = true
combine-as-imports = true

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

[format]
preview = true
Installing MkDocs

To install mkdocs:

pip install mkdocs
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

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
extend-exclude = [
    "docs",
]
target-version = "py312"

[lint]
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",
    "COM812",
    "D100",
    "D101",
    "D102",
    "D103",
    "D104",
    "D105",
    "D106",
    "D107",
    "D203",
    "D204",
    "D213",
    "D215",
    "D400",
    "D401",
    "D404",
    "D406",
    "D407",
    "D408",
    "D409",
    "D413",
    "ISC001",
    "PLR0912",
    "PLR0913",
    "PLR0915",
    "SLF001",
    "TRY003",
]

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

[lint.isort]
lines-after-imports = 2
force-sort-within-sections = true
combine-as-imports = true

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

[format]
preview = true
Installing Ruff

To install ruff:

pip install ruff
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.12"
disable_error_code = [
    "assignment",
    "misc",
    "import",
    "has-type",
]
pretty = true
plugins = [
    "pydantic.mypy",
]
Installing MyPy

To install mypy:

pip install mypy
More information

Page info
Code for this page
mknodes.manual.dev_section._
@nav.route.page("Dev Tools", icon="wrench")
def _(page: mk.MkPage):
    page += mk.MkDevTools()
Resources
Resources(css=[],
          markdown_extensions={'admonition': {},
                               'attr_list': {},
                               'md_in_html': {},
                               'pymdownx.details': {},
                               'pymdownx.emoji': {'emoji_generator': <function to_svg at 0x7f6e52627c40>,
                                                  'emoji_index': <function twemoji at 0x7f6e52627b00>},
                               'pymdownx.highlight': {'anchor_linenums': True,
                                                      'line_spans': '__span',
                                                      'pygments_lang_class': True},
                               'pymdownx.magiclink': {'repo': 'mkdocs_mknodes',
                                                      'repo_url_shorthand': True,
                                                      'user': 'phil65'},
                               'pymdownx.superfences': {}},
          plugins=[],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mkdocs-mknodes/mkdocs-mknodes/.venv/lib/python3.12/site-packages/mknodes/manual/dev_section.py
  source_function: null
  source_line_no: 18
icon: material/wrench
template: SUMMARY.html
title: Dev Tools