Skip to content

Commit

Permalink
add support for mypy
Browse files Browse the repository at this point in the history
Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com>
  • Loading branch information
Zeitsperre committed Jan 3, 2025
1 parent a0712ef commit 7e26738
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ repos:
rev: v2.13
hooks:
- id: vulture
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
hooks:
- id: mypy
{%- if cookiecutter.use_black == 'y' %}
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
Expand Down
3 changes: 2 additions & 1 deletion {{cookiecutter.project_slug}}/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#
import os
import sys
from typing import Any

sys.path.insert(0, os.path.abspath('..'))

Expand Down Expand Up @@ -138,7 +139,7 @@

# -- Options for LaTeX output ------------------------------------------

latex_elements = {
latex_elements: dict[str, Any] = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def main():
parser.add_argument('_', nargs='*')
args = parser.parse_args()

print("Arguments: " + str(args._))
print(f"Arguments: {args._}")
print("Replace this message by putting your code into {{cookiecutter.project_slug}}.cli.main")
return 0

Expand All @@ -25,7 +25,7 @@ def main():


@click.command()
def main(args=None):
def main(args=None) -> int:
"""Console script for {{cookiecutter.project_slug}}."""
click.echo(
"Replace this message by putting your code into {{cookiecutter.project_slug}}.cli.main",
Expand All @@ -43,8 +43,8 @@ def main(args=None):
console = Console()


@app.command()
def main():
@app.command() # type: ignore[misc]
def main() -> None:
"""Console script for {{cookiecutter.project_slug}}."""
console.print(
"Replace this message by putting your code into {{cookiecutter.project_slug}}.cli.main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ def test_command_line_interface(self):

def test_package_metadata():
"""Test the package metadata."""
project = find_spec("{{ cookiecutter.project_slug }}").submodule_search_locations[0]
project = find_spec("{{ cookiecutter.project_slug }}")

metadata = pathlib.Path(project).resolve().joinpath("__init__.py")
assert project is not None
assert project.submodule_search_locations is not None
location = project.submodule_search_locations[0]

metadata = pathlib.Path(location).resolve().joinpath("__init__.py")

with metadata.open() as f:
contents = f.read()
Expand Down

0 comments on commit 7e26738

Please sign in to comment.