Skip to content

Commit

Permalink
add entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Broderick committed Apr 27, 2024
1 parent 34e83d9 commit ae2b184
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ repos:
hooks:
- id: python_file_name_check
name: "Python: File name check"
entry: "python ./src/precommithooks/__main__.py"
entry: "python ./src/precommithooks/checknames.py"
language: python
pass_filenames: true
types: [file, python]
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pyproject-api==1.6.1
# via tox
pyproject-hooks==1.0.0
# via build
pytest==8.1.2
pytest==8.2.0
# via
# pytest-cov
# pytest-pretty
Expand Down
5 changes: 3 additions & 2 deletions src/precommithooks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Precommithooks package."""

from .__main__ import Mode as Mode
from .__main__ import check_names as check_names
from .checknames import Mode as Mode
from .checknames import check_names as check_names
from .checknames import main as main
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def check_names( # noqa: C901, PLR0912
return ExitCode.OK


def main(argv: Sequence[str] | None = None) -> int:
def main() -> int:
"""Get files from passed argument."""
parser = argparse.ArgumentParser()
parser.add_argument(
Expand All @@ -112,7 +112,7 @@ def main(argv: Sequence[str] | None = None) -> int:
action="store_true",
help="Ignore test files",
)
args = parser.parse_args(argv)
args = parser.parse_args()
mode = Mode.NON_STRICT
short_name_limit = (
int(args.short_name_limit)
Expand All @@ -121,14 +121,12 @@ def main(argv: Sequence[str] | None = None) -> int:
)
if args.strict:
mode = Mode.STRICT
if argv is not None:
return check_names(
args.filenames,
short_name_limit=short_name_limit,
ignore_test_files=args.ignore_test_files,
mode=mode,
)
return ExitCode.OK
return check_names(
args.filenames,
short_name_limit=short_name_limit,
ignore_test_files=args.ignore_test_files,
mode=mode,
)


if __name__ == "__main__":
Expand Down

0 comments on commit ae2b184

Please sign in to comment.