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

pre-commit hook with stages: [commit] #144

Open
LeskoIam opened this issue May 28, 2024 · 3 comments
Open

pre-commit hook with stages: [commit] #144

LeskoIam opened this issue May 28, 2024 · 3 comments

Comments

@LeskoIam
Copy link

When using docstr-coverage with pre-commit and using stages: [commit] e.g.:

  - repo: https://github.com/HunterMcGushion/docstr_coverage
    rev: v2.3.2
    hooks:
      - id: docstr-coverage
        args: ["--verbose", "3", "--percentage-only"]
        verbose: true
        stages: [commit]

.docstr.yaml

# --skip-file-doc, -f - Ignore module docstrings (at the top of files)
skip_file_doc: True
# --skip-class-def, -c - Ignore docstrings of class definitions
skip_class_def: True
# --follow-links, -l - Follow symlinks
follow_links: False
# --skip-magic, -m - Ignore all magic methods (except __init__)
skip_magic: True
# --skip-private, -P - Ignore private functions (starting with a single underscore)
# skip_private: True
accept_empty: True

even though *.py files are present in commit

identity.................................................................Passed
- hook id: identity
- duration: 0.06s
.pre-commit-config.yaml
tests/smth/test_smth_model.py

docstr-coverage passes with warning

docstr-coverage..........................................................Passed
- hook id: docstr-coverage
- duration: 0.19s
C:\Users\...\...\Lib\site-packages\docstr_coverage\cli.py:288: UserWarning: No Python files found in specified paths. Processing aborted
  warnings.warn("No Python files found in specified paths. Processing aborted")

Any input on this? Thank you!

@HunterMcGushion
Copy link
Owner

Hi, @LeskoIam, thanks for reporting this. Are you able to reproduce this problem when running docstr-coverage manually (outside of pre-commit hooks)?

@LeskoIam
Copy link
Author

LeskoIam commented Jun 5, 2024

Hi @HunterMcGushion and thanks for looking into this!

I can reproduce this by manually running the hook, e.g.:


(.venv) ~\workspace\...\ git:[LeskoIam/reproduce-docstr-coverage-issue]
pre-commit run identity
identity.................................................................Passed
- hook id: identity
- duration: 0.06s

.pre-commit-config.yaml
src/my_tests/smth2.py


(.venv) ~\workspace\...\ git:[LeskoIam/reproduce-docstr-coverage-issue]
pre-commit run docstr-coverage
docstr-coverage..........................................................Failed
- hook id: docstr-coverage
- duration: 0.25s
- exit code: 1

No Python files found. Use `--accept-empty` to exit with code 0 if you expect this case, or specify the paths you'd like to check via command line arguments or the config file.

A few details

docstr-coverage==2.3.2
pre-commit==3.7.1
# .pre-commit-config.yaml

repos:
  - repo: meta
    hooks:
      - id: identity

  - repo: https://github.com/HunterMcGushion/docstr_coverage
    rev: v2.3.2
    hooks:
      - id: docstr-coverage
        args: ["--verbose", "3", "--percentage-only"]
        verbose: true
        stages: [commit]

@LeskoIam
Copy link
Author

LeskoIam commented Jun 10, 2024

Hey! I forked the repo and added test for single .py file in directory which is passing without a problem.

So I think the problem is with pre-commit package. I'll try to add specific tests for pre-commit hooks.

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

2 participants