Skip to content

Commit

Permalink
Fix: Mypy configuration was inline
Browse files Browse the repository at this point in the history
Solution: Use a dedicated section of pyproject.toml for the configuration of Mypy.

This also adds `check_untyped_defs` to force type checking on all code, annotated or not.
  • Loading branch information
hoh committed Mar 6, 2024
1 parent 68eec0c commit 1daefc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ python = ["3.9", "3.10", "3.11", "3.12"]
detached = true
dependencies = [
"black==24.1.1",
"mypy==1.6.0",
"mypy==1.8.0",
"ruff==0.1.15",
"isort==5.13.2",
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --ignore-missing-imports --explicit-package-bases {args:src/aleph/vm/ tests/ examples/example_fastapi runtimes/aleph-debian-12-python}"
typing = "mypy {args:src/aleph/vm/ tests/ examples/example_fastapi runtimes/aleph-debian-12-python}"
style = [
# "ruff {args:.}",
"black --check --diff {args:.}",
Expand All @@ -139,6 +139,14 @@ target-version = ["py39"]
line-length = 120
#skip-string-normalization = true

[tool.mypy]
python_version = "3.9"
install_types = true
non_interactive = true
ignore_missing_imports = true
explicit_package_bases = true
check_untyped_defs = true

[tool.ruff]
target-version = "py39"
line-length = 120
Expand Down
4 changes: 3 additions & 1 deletion src/aleph/vm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def is_running(self) -> bool:
def is_stopping(self) -> bool:
return bool(self.times.stopping_at and not self.times.stopped_at)

@property
def is_program(self) -> bool:
return isinstance(self.message, ProgramContent)

Expand Down Expand Up @@ -123,7 +124,8 @@ def uses_payment_stream(self) -> bool:
return self.message.payment and self.message.payment.is_stream

@property
def has_resources(self):
def has_resources(self) -> bool:
assert self.vm, "The VM attribute has to be set before calling has_resources()"

Check warning on line 128 in src/aleph/vm/models.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/models.py#L128

Added line #L128 was not covered by tests
return self.vm.resources_path.exists() if self.hypervisor == HypervisorType.firecracker else True

def __init__(
Expand Down

0 comments on commit 1daefc3

Please sign in to comment.