Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide "integrations" #7

Closed
pawamoy opened this issue Feb 5, 2023 · 0 comments
Closed

Provide "integrations" #7

pawamoy opened this issue Feb 5, 2023 · 0 comments

Comments

@pawamoy
Copy link
Owner

pawamoy commented Feb 5, 2023

Is your feature request related to a problem? Please describe.
I don't like polluting my duties.py with lots of boilerplate code needed to run some tools that don't expose clean entrypoints.

For example, I'm currently playing with blacken-docs, and this is the code I have to put in my duties:

import black
from blacken_docs import format_file

def blacken_docs():
    py_md_files = set()
    for src_path in list(PY_SRC_PATHS) + [Path("docs")]:
        if src_path.is_file():
            py_md_files.add(src_path.as_posix())
        else:
            py_md_files |= set(path.as_posix() for path in src_path.rglob("*.py"))
            py_md_files |= set(path.as_posix() for path in src_path.rglob("*.md"))

    black_mode = black.Mode()
    retv = 0
    for filename in sorted(py_md_files):
        retv |= format_file(filename, black_mode, skip_errors=False, rst_literal_blocks=False)
    return retv

ctx.run(blacken_docs, title="Formatting code blocks")

See other examples here: pawamoy/copier-pdm#21.

Describe the solution you'd like
I wonder if duty couldn't provide an integrations subpackage that offers Python callables to run many different tools and their commands.

For example, I'd like to import a function blacken_docs from duty.integrations.blacken_docs that accepts lists of paths to check, recursively, with a list of extensions to pick up maybe, and probably other options (that just cater to my own needs first).

Describe alternatives you've considered
Copy/paste, or inclusion in my copier-pdm template (which is kinda copy/paste anyway).

Additional context
The goal is re-usability and performance. We don't want to run subprocesses, or have argparse parse arguments again and again.

Current integrations I'd like to have:

  • flake8 check (critical)
  • mkdocs build strict (critical)
  • mypy check (critical)
  • safety check
  • blacken-docs
pawamoy added a commit that referenced this issue Feb 18, 2023
@pawamoy pawamoy closed this as completed Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant