Skip to content

Commit

Permalink
try fixing mypy 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pfandzelter committed Mar 26, 2024
1 parent 4afbf9b commit 0f2a56f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 39 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: mypy-check
uses: theCapypara/mypy-check@master
uses: jpetrucciani/mypy-check@master
with:
path: ""
requirements: types-toml
mypy_flags: "-p celestial --config setup.cfg"
- name: mypy-check2
uses: theCapypara/mypy-check@master
with:
requirements: "types-toml numpy types-request mypy-protobuf"
requirements: "types-toml numpy types-requests mypy-protobuf"
path: "*.py"
mypy_flags: "--config setup.cfg"

Expand Down
4 changes: 3 additions & 1 deletion celestial/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def register(self) -> proto.celestial.celestial_pb2.RegisterResponse:
"""
request = proto.celestial.celestial_pb2.RegisterRequest(host=self.num)

response = self.stub.Register(request)
response: proto.celestial.celestial_pb2.RegisterResponse = self.stub.Register(
request
)

# others currently not used
self.peer_public_key = response.peer_public_key
Expand Down
48 changes: 24 additions & 24 deletions celestial/proto_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
MAX_DIFF_UPDATE_SIZE = 100_000


def _machineID_group(m: celestial.types.MachineID_dtype) -> int:
return typing.cast(int, celestial.types.MachineID_group(m))


def _machineID_id(m: celestial.types.MachineID_dtype) -> int:
return typing.cast(int, celestial.types.MachineID_id(m))


def make_init_request(
hosts: typing.List[celestial.host.Host],
machines: typing.Dict[
Expand All @@ -53,8 +61,8 @@ def make_init_request(

for m in machines[h.num]:
mid = proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(m[0]),
id=celestial.types.MachineID_id(m[0]),
group=_machineID_group(m[0]),
id=_machineID_id(m[0]),
)

mc = proto.celestial.celestial_pb2.InitRequest.Machine.MachineConfig(
Expand Down Expand Up @@ -114,8 +122,8 @@ def make_update_request_iter(
machine_diffs=[
proto.celestial.celestial_pb2.StateUpdateRequest.MachineDiff(
id=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(m_id),
id=celestial.types.MachineID_id(m_id),
group=_machineID_group(m_id),
id=_machineID_id(m_id),
),
active=proto.celestial.celestial_pb2.VM_STATE_STOPPED
if m_state == celestial.types.VMState.STOPPED
Expand All @@ -131,42 +139,34 @@ def make_update_request_iter(
network_diffs=[
proto.celestial.celestial_pb2.StateUpdateRequest.NetworkDiff(
source=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(source),
id=celestial.types.MachineID_id(source),
group=_machineID_group(source),
id=_machineID_id(source),
),
target=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(target),
id=celestial.types.MachineID_id(target),
group=_machineID_group(target),
id=_machineID_id(target),
),
latency=celestial.types.Link_latency_us(link),
bandwidth=celestial.types.Link_bandwidth_kbits(link),
blocked=False,
next=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(
celestial.types.Link_next_hop(link)
),
id=celestial.types.MachineID_id(
celestial.types.Link_next_hop(link)
),
group=_machineID_group(celestial.types.Link_next_hop(link)),
id=_machineID_id(celestial.types.Link_next_hop(link)),
),
prev=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(
celestial.types.Link_prev_hop(link)
),
id=celestial.types.MachineID_id(
celestial.types.Link_prev_hop(link)
),
group=_machineID_group(celestial.types.Link_prev_hop(link)),
id=_machineID_id(celestial.types.Link_prev_hop(link)),
),
)
if not celestial.types.Link_blocked(link)
else proto.celestial.celestial_pb2.StateUpdateRequest.NetworkDiff(
source=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(source),
id=celestial.types.MachineID_id(source),
group=_machineID_group(source),
id=_machineID_id(source),
),
target=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(target),
id=celestial.types.MachineID_id(target),
group=_machineID_group(target),
id=_machineID_id(target),
),
blocked=True,
)
Expand Down
6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@
python_version = 3.11
warn_unused_configs = True
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_return_any = True
no_implicit_reexport = True
strict_equality = True
ignore_missing_imports = True
show_column_numbers = True
follow_imports = skip
plugins = numpy.typing.mypy_plugin

0 comments on commit 0f2a56f

Please sign in to comment.