Skip to content

Commit

Permalink
fix: fix type annotations for newest mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
K900 committed Oct 25, 2023
1 parent 38117a7 commit 4384117
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions nixops/nix_expr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import abstractmethod
import functools
import string
from typing import Iterable, Optional, Any, List, Tuple, Union, Dict
from typing import Iterable, Optional, Any, List, Sequence, Tuple, Union, Dict
from textwrap import dedent

__all__ = ["py2nix", "nix2py", "nixmerge", "expand_dict", "RawValue", "Function"]
Expand Down Expand Up @@ -81,12 +81,12 @@ class Container(object):
def __init__(
self,
prefix: str,
children: List,
children: Sequence[Union[RawValue, "Container"]],
suffix: str,
inline_variant: Optional[ValueLike] = None,
):
self.prefix: str = prefix
self.children: List = children
self.children = children
self.suffix: str = suffix
self.inline_variant = inline_variant

Expand All @@ -99,7 +99,7 @@ def get_min_length(self) -> int:
+ len(self.suffix)
+ 1
+ len(self.children)
+ sum([child.get_min_length() for child in self.children])
+ sum([child.get_min_length() or 0 for child in self.children])
)

def is_inlineable(self) -> bool:
Expand Down
1 change: 1 addition & 0 deletions nixops/plugins/hookspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ def plugin() -> Plugin:
"""
Register a plugin base class
"""
raise NotImplementedError
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ testpaths = [ "tests" ]
[tool.mypy]
warn_return_any = true
warn_unused_configs = true
check_untyped_defs = true
ignore_missing_imports = true

["tool.mypy-pytest.*"]
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_rebooting_reboots.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def run_check(self):
self.depl.deploy()
self.check_command("touch /run/not-rebooted")
self.depl.reboot_machines(wait=True)
assert self.depl.active
m = list(self.depl.active.values())[0]
m.check()
assert m.state == m.UP
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_rollback_rollsback.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestRollbackRollsback(SingleMachineTest):
def setup_method(self):
super(TestRollbackRollsback, self).setup_method()
self.depl.network_expr = NetworkFile(rollback_spec)
self.depl.nix_exprs = self.depl.nix_exprs + [rollback_spec]
self.depl.nix_exprs = self.depl.nix_exprs + [rollback_spec] # type: ignore

def run_check(self):
self.depl.deploy()
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_send_keys_sends_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestSendKeysSendsKeys(SingleMachineTest):

def setup_method(self):
super(TestSendKeysSendsKeys, self).setup_method()
self.depl.nix_exprs = self.depl.nix_exprs + [
self.depl.nix_exprs = self.depl.nix_exprs + [ # type: ignore
secret_key_spec,
elsewhere_key_spec,
]
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_ssh_key_pair_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def setup_method(self):
def test_evaluate(self):
self.depl.evaluate()

assert "ssh-key" in self.depl.definitions
assert self.depl.definitions and "ssh-key" in self.depl.definitions
1 change: 1 addition & 0 deletions tests/functional/test_starting_starts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def run_check(self):
self.depl.deploy()
self.depl.stop_machines()
self.depl.start_machines()
assert self.depl.active
m = list(self.depl.active.values())[0]
m.check()
assert m.state == m.UP
1 change: 1 addition & 0 deletions tests/functional/test_stopping_stops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ class TestStoppingStops(single_machine_test.SingleMachineTest):
def run_check(self):
self.depl.deploy()
self.depl.stop_machines()
assert self.depl.active
m = list(self.depl.active.values())[0]
assert m.state == m.STOPPED
6 changes: 3 additions & 3 deletions tests/unit/test_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Sequence
from typing import Any, Sequence
import json
from nixops.logger import Logger
from io import StringIO
Expand Down Expand Up @@ -49,7 +49,7 @@ def test_immutable_dict(self):

# Assert that the shape of the immutable dict is the same as the input dict

i = util.ImmutableMapping(d)
i: util.ImmutableMapping[str, Any] = util.ImmutableMapping(d)
self.assertEqual(d["foo"], i["foo"])

tup = i["list"]
Expand All @@ -63,7 +63,7 @@ def test_immutable_dict(self):
self.assertTrue(isinstance(dic, util.ImmutableMapping))
self.assertEqual(
dic["x"],
d["nested"]["x"],
d["nested"]["x"], # type: ignore
)

dic_l = i["nested_in_list"][0]
Expand Down

0 comments on commit 4384117

Please sign in to comment.