Skip to content

Commit

Permalink
Address mypy complains
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Dec 1, 2024
1 parent 757d964 commit d72fcd2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/plumpy/communications.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def convert_to_comm(
def _passthrough(*args: Any, **kwargs: Any) -> bool:
sender = kwargs.get('sender', args[1])
subject = kwargs.get('subject', args[2])
return callback.is_filtered(sender, subject) # type: ignore[attr-defined]
return callback.is_filtered(sender, subject)
else:

def _passthrough(*args: Any, **kwargs: Any) -> bool: # pylint: disable=unused-argument
Expand Down
4 changes: 2 additions & 2 deletions src/plumpy/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def wrapped_fn(self: Any, *args: Any, **kwargs: Any) -> Callable[..., Any]:

return func(self, *args, **kwargs)
else:
wrapped_fn = func
wrapped_fn = func # type: ignore[assignment]

return wrapped_fn

Expand Down Expand Up @@ -60,7 +60,7 @@ def wrapped_fn(self: Any, *args: Any, **kwargs: Any) -> Callable[..., Any]:

return func(self, *args, **kwargs)
else:
wrapped_fn = func
wrapped_fn = func # type: ignore[assignment]

return wrapped_fn

Expand Down
22 changes: 19 additions & 3 deletions src/plumpy/workchains.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

import abc
import asyncio
import collections
import inspect
import logging
import re
from typing import Any, Callable, Dict, Hashable, List, Mapping, Optional, Sequence, Tuple, Type, Union, cast
from typing import (
Any,
Callable,
Dict,
Hashable,
List,
Mapping,
MutableSequence,
Optional,
Sequence,
Tuple,
Type,
Union,
cast,
)

import kiwipy

Expand Down Expand Up @@ -327,15 +343,15 @@ class _Block(_Instruction, collections.abc.Sequence):

def __init__(self, instructions: Sequence[Union[_Instruction, WC_COMMAND_TYPE]]) -> None:
# Build up the list of commands
comms = []
comms: MutableSequence[_Instruction | _FunctionCall] = []
for instruction in instructions:
if not isinstance(instruction, _Instruction):
# Assume it's a function call
comms.append(_FunctionCall(instruction))
else:
comms.append(instruction)

self._instruction: List[Union[_Instruction, _FunctionCall]] = comms
self._instruction: MutableSequence[_Instruction | _FunctionCall] = comms

def __getitem__(self, index: int) -> Union[_Instruction, _FunctionCall]: # type: ignore
return self._instruction[index]
Expand Down
2 changes: 2 additions & 0 deletions test/test_workchains.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ def step2(self):
workchain = SimpleWorkChain()
workchain.add_process_listener(TestListener())

workchain.execute()

self.assertEqual(process_finished_count, 1)

workchain_checkpoint = persister.load_checkpoint(workchain.pid, 'step1').unbundle()
Expand Down

0 comments on commit d72fcd2

Please sign in to comment.