Skip to content

Commit

Permalink
Add pre-commit and mypy config files
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprengere committed Jan 23, 2025
1 parent 42594d1 commit 5d785dc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: "meta"
hooks:
- id: "check-hooks-apply"
- id: "check-useless-excludes"

- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v5.0.0"
hooks:
- id: "check-added-large-files"
- id: "check-merge-conflict"
- id: "check-yaml"

- repo: "https://github.com/astral-sh/ruff-pre-commit"
rev: "v0.9.2"
hooks:
- id: "ruff"
args: ["--fix"]

- repo: "https://github.com/psf/black-pre-commit-mirror"
rev: "24.10.0"
hooks:
- id: "black"
language_version: "python3.11"
3 changes: 2 additions & 1 deletion package/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ._version import __version__


def main():
def main() -> int:
import argparse

parser = argparse.ArgumentParser(prog="Squarer of ints")
Expand All @@ -14,6 +14,7 @@ def main():
)
args = parser.parse_args()
print(f"Square of {args.x} is {square(args.x)}")
return 0


if __name__ == "__main__":
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,15 @@ ignore = []
line-length = 88
target-version = ["py39"]
extend-exclude = "doc"

[tool.mypy]
warn_return_any = "True"
warn_unused_configs = "True"
strict_optional = "True"
ignore_missing_imports = "True"
disallow_any_unimported = "True"
check_untyped_defs = "True"
disallow_untyped_defs = "True"
no_implicit_optional = "True"
show_error_codes = "True"
warn_unused_ignores = "True"
2 changes: 1 addition & 1 deletion test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"x,res",
[(1, 1), (2, 4), (-1, 1), (0, 0)],
)
def test_square(x, res):
def test_square(x: int, res: int) -> None:
assert square(x) == res

0 comments on commit 5d785dc

Please sign in to comment.