Skip to content

Commit

Permalink
Reinstall mypy
Browse files Browse the repository at this point in the history
I accidentally removed mypy when I installed ruff, but ruff is not a type checker.
I will reinstall mypy.

https://docs.astral.sh/ruff/faq/#how-does-ruff-compare-to-mypy-or-pyright-or-pyre
  • Loading branch information
kitsuyui committed Jul 4, 2024
1 parent ec69cf9 commit 4b0c520
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 18 deletions.
72 changes: 65 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pytest-cov = "*"
poethepoet = "*"
setuptools-scm = "*"
build = "*"
mypy = "*"

[build-system]
requires = ["setuptools", "setuptools_scm"]
Expand All @@ -31,19 +32,15 @@ write_to = "timeout_iterator/_version.py"
test = "pytest"
coverage-xml = "pytest --cov=timeout_iterator --doctest-modules --cov-report=xml"
format = "ruff format timeout_iterator tests"
check = "ruff check timeout_iterator tests"
check = [
{ cmd = "ruff check timeout_iterator tests" },
{ cmd = "mypy timeout_iterator tests" },
]
build = "python -m build"

[tool.mypy]
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
strict = true
ignore_missing_imports = false

[tool.mypy-tests."*"]
disallow_untyped_defs = false
warn_return_any = false
ignore_missing_imports = true

[tool.ruff]
line-length = 79
6 changes: 5 additions & 1 deletion timeout_iterator/terminate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from collections.abc import Iterable
from typing import TypeVar
import datetime
import signal


T = TypeVar("T")


# NOTE: float type accepts int
# https://peps.python.org/pep-0484/#the-numeric-tower
def terminate(iterable: Iterable, seconds: float) -> Iterable:
def terminate(iterable: Iterable[T], seconds: float) -> Iterable[T]:
"""Timeout iterator
This iterator forcibly terminates a running task after the specified number of seconds.
Expand Down
6 changes: 5 additions & 1 deletion timeout_iterator/without_terminate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from collections.abc import Iterable
from typing import TypeVar
import datetime


T = TypeVar("T")


# NOTE: float type accepts int
# https://peps.python.org/pep-0484/#the-numeric-tower
def without_terminate(iterable: Iterable, seconds: float) -> Iterable:
def without_terminate(iterable: Iterable[T], seconds: float) -> Iterable[T]:
"""Timeout iterator
This iterator times out after the specified number of seconds.
Expand Down

0 comments on commit 4b0c520

Please sign in to comment.