Skip to content

Commit

Permalink
Type check with mypy.
Browse files Browse the repository at this point in the history
Lint with ruff.
  • Loading branch information
eskildsf committed Dec 21, 2024
1 parent ff4aeb6 commit 5b2b4e3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Reloading
[![CI](https://github.com/nneskildsf/reloading/actions/workflows/CI.yml/badge.svg)](https://github.com/nneskildsf/reloading/actions/workflows/CI.yml)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
[![Linting: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

A Python utility to reload a function or loop body from source on each iteration without losing state.

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ development = [
"nbformat",
"flake8",
"pyright",
"mypy",
"ruff",
"build",
]

Expand Down
2 changes: 1 addition & 1 deletion reloading/reloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def reloading(fn_or_seq_or_bool: Optional[
source before each invocation or iteration, respectively.
"""
if fn_or_seq_or_bool is not None:
if isinstance(fn_or_seq_or_bool, Callable):
if callable(fn_or_seq_or_bool):
return _reloading_function(fn_or_seq_or_bool)
elif (isinstance(fn_or_seq_or_bool, Iterable) or
isinstance(fn_or_seq_or_bool, bool)):
Expand Down
4 changes: 2 additions & 2 deletions reloading/test_reloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def run_and_update_source(init_src, updated_src=None, update_after=0.5):
f.flush()

try:
stdout, _ = proc.communicate(timeout=2)
stdout = stdout.decode("utf-8")
stdout_bytes, _ = proc.communicate(timeout=2)
stdout = stdout_bytes.decode("utf-8")
has_error = False
except Exception:
stdout = ""
Expand Down

0 comments on commit 5b2b4e3

Please sign in to comment.