Python icon indicating copy to clipboard operation
Python copied to clipboard

Add docstring checker to pre-commit

Open Cjkjvfnby opened this issue 3 years ago • 2 comments

Describe your change:

  • Add flake8 docstring to the pre-commit hook
  • Add global configuration for checks
  • Add per-file exclusion to the violation.
  • Minor doc fixes
  • [ ] Add an algorithm?
  • [ ] Fix a bug or typo in an existing algorithm?
  • [x] Documentation change?

Checklist:

  • [x] I have read CONTRIBUTING.md.
  • [ ] This pull request is all my own work -- I have not plagiarized.
  • [ ] I know that pull requests will not be merged if they fail the automated tests.
  • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • [ ] All new Python files are placed inside an existing directory.
  • [ ] All filenames are in all lowercase characters with no spaces or dashes.
  • [ ] All functions and variable names follow Python naming conventions.
  • [ ] All function parameters and return values are annotated with Python type hints.
  • [ ] All functions have doctests that pass the automated testing.
  • [ ] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

The script I was using to generate per-file-ignore list. (copy paste pre-commit output into a)

a = '''
ciphers/vigenere_cipher.py:1:1: D100 Missing docstring in public module
ciphers/vigenere_cipher.py:4:1: D103 Missing docstring in public function
'''.strip()

result = {}

for line in a.split("\n"):
    file_name, _, tail = line.partition(":")
    _, _, warning = tail.rpartition(": ")
    code, _, _ = warning.partition(" ")
    result.setdefault(file_name, set()).add(code)

for file_name, errors in sorted(result.items()):
    print(f"    {file_name}: {', '.join(sorted(errors))}")

Cjkjvfnby avatar Nov 05 '22 11:11 Cjkjvfnby

Please fix git conflicts.

cclauss avatar Nov 05 '22 11:11 cclauss

Every other PR merged could make this one obsolete, because new undocumented things were added.

After merging this one I'll run extra checks to ensure that no unsuppressed warnings left.

Cjkjvfnby avatar Nov 05 '22 18:11 Cjkjvfnby

Closing it since it became outdated. It would be easy to recreate it from a scratch if needed.

Cjkjvfnby avatar Mar 13 '23 22:03 Cjkjvfnby