Skip to content

Auto-scan source root in export-functions hook instead of hard-coding module paths#1633

Closed
Copilot wants to merge 8 commits intomainfrom
copilot/avoid-hardcoding-module-names
Closed

Auto-scan source root in export-functions hook instead of hard-coding module paths#1633
Copilot wants to merge 8 commits intomainfrom
copilot/avoid-hardcoding-module-names

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 29, 2026

The export-functions hook listed specific module files as positional args in .pre-commit-config.yaml, coupling the config to the project's internal module structure. This rots as modules are added/removed.

Hook changes (hooks/export-functions.py)

  • Removed positional source_files argument; now recursively discovers all .py files under --source-root
  • Added --strict flag — fails if any public function lacks a docstring
  • Added AUTO_EXCLUDED set (e.g. _version.py) consistent with export-module-tree.py
  • Scoped to module-level functions via ast.iter_child_nodes() instead of ast.walk()

Config change (.pre-commit-config.yaml)

Before (18 lines, hard-coded paths):

args:
  - "--output-file=docs/functions.txt"
  - "--source-root=src"
  - "src/usethis/_deps.py"
  - "src/usethis/_console.py"
  - ...  # 11 more hard-coded paths

After:

args: ["--source-root=src/usethis", "--output-file=docs/functions.txt", "--strict"]

Docstrings

  • Added one-line docstrings to 112 public functions across the codebase to comply with --strict
  • docs/functions.txt regenerated: 26 → 191 entries
  • AGENTS.md sync block updated accordingly

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 7 commits March 29, 2026 22:10
…reference

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Add concise one-line docstrings in imperative mood to 37 public
functions across 8 files in src/usethis/_core/ that were missing them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Add concise one-line docstrings in imperative mood to 13 public functions
across 6 files:
- pre_commit/core.py: remove_pre_commit_config()
- pre_commit/hooks.py: insert_repo(), add_placeholder_hook(), get_hook_ids(), extract_hook_ids()
- pytest/core.py: add_pytest_dir(), remove_pytest_dir()
- readme/path.py: get_readme_path(), get_markdown_readme_path()
- _pipeweld/containers.py: parallel(), series(), depgroup()
- _pipeweld/func.py: get_endpoint()

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Add concise one-line docstrings in imperative mood to 39 public functions
across 19 files that were missing them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
…from --source-root with --strict mode

- Rewrite hooks/export-functions.py to recursively scan all .py files under --source-root instead of accepting positional source file arguments
- Add --strict flag that fails if any public function is missing a docstring
- Add AUTO_EXCLUDED set for files like _version.py
- Update .pre-commit-config.yaml to use --source-root=src/usethis --strict (no hard-coded file paths)
- Add docstrings to 112 public functions across the codebase to comply with --strict
- Regenerate docs/functions.txt with comprehensive function reference (191 entries)
- Update AGENTS.md sync block with new functions.txt content

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/7de1d7f1-5f63-4ecc-87a7-1f34787c4b92

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix agent config to avoid hard-coding module names Auto-scan source root in export-functions hook instead of hard-coding module paths Mar 29, 2026
Copilot AI requested a review from nathanjmcdougall March 29, 2026 22:30
@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

This was also premature.

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

Successfully merging this pull request may close these issues.

Agent config to avoid hard-coding module names in prek config

2 participants