diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-06-19 07:03:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-06-19 07:03:44 +0000 |
commit | 9262e31316a16180044e0e28a2740238f8aef5c4 (patch) | |
tree | 49b2bc070018965707ec237623da9932c880fae4 /pre_commit_hooks/check_docstring_first.py | |
parent | Adding debian version 4.1.0-1. (diff) | |
download | pre-commit-hooks-9262e31316a16180044e0e28a2740238f8aef5c4.tar.xz pre-commit-hooks-9262e31316a16180044e0e28a2740238f8aef5c4.zip |
Merging upstream version 4.3.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit_hooks/check_docstring_first.py')
-rw-r--r-- | pre_commit_hooks/check_docstring_first.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pre_commit_hooks/check_docstring_first.py b/pre_commit_hooks/check_docstring_first.py index 875c0fb..d55f08a 100644 --- a/pre_commit_hooks/check_docstring_first.py +++ b/pre_commit_hooks/check_docstring_first.py @@ -1,8 +1,9 @@ +from __future__ import annotations + import argparse import io import tokenize from tokenize import tokenize as tokenize_tokenize -from typing import Optional from typing import Sequence NON_CODE_TOKENS = frozenset(( @@ -27,13 +28,13 @@ def check_docstring_first(src: bytes, filename: str = '<unknown>') -> int: if tok_type == tokenize.STRING and scol == 0: if found_docstring_line is not None: print( - f'{filename}:{sline} Multiple module docstrings ' + f'{filename}:{sline}: Multiple module docstrings ' f'(first docstring on line {found_docstring_line}).', ) return 1 elif found_code_line is not None: print( - f'{filename}:{sline} Module docstring appears after code ' + f'{filename}:{sline}: Module docstring appears after code ' f'(code seen on line {found_code_line}).', ) return 1 @@ -45,7 +46,7 @@ def check_docstring_first(src: bytes, filename: str = '<unknown>') -> int: return 0 -def main(argv: Optional[Sequence[str]] = None) -> int: +def main(argv: Sequence[str] | None = None) -> int: parser = argparse.ArgumentParser() parser.add_argument('filenames', nargs='*') args = parser.parse_args(argv) |