Skip to content

Commit ccf2b90

Browse files
Fix pyright errors in the template
1 parent d91c115 commit ccf2b90

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

template/src/{{ package_name }}/__main__.py.jinja

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
from argparse import ArgumentParser
2+
from collections.abc import Sequence
23

34
from . import __version__
45

56
__all__ = ["main"]
67

78

8-
def main(args=None):
9+
def main(args: Sequence[str] | None = None) -> None:
910
parser = ArgumentParser()
10-
parser.add_argument("-v", "--version", action="version", version=__version__)
11-
args = parser.parse_args(args)
11+
parser.add_argument(
12+
"-v",
13+
"--version",
14+
action="version",
15+
version=__version__,
16+
)
17+
parser.parse_args(args)
1218

1319

1420
# test with: python -m {{package_name}}

tests/conftest.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from typing import Any
23

34
import pytest
45

@@ -7,9 +8,14 @@
78
if os.getenv("PYTEST_RAISE", "0") == "1":
89

910
@pytest.hookimpl(tryfirst=True)
10-
def pytest_exception_interact(call):
11-
raise call.excinfo.value
11+
def pytest_exception_interact(call: pytest.CallInfo[Any]):
12+
if call.excinfo is not None:
13+
raise call.excinfo.value
14+
else:
15+
raise RuntimeError(
16+
f"{call} has no exception data, an unknown error has occurred"
17+
)
1218

1319
@pytest.hookimpl(tryfirst=True)
14-
def pytest_internalerror(excinfo):
20+
def pytest_internalerror(excinfo: pytest.ExceptionInfo[Any]):
1521
raise excinfo.value

0 commit comments

Comments
 (0)