Skip to content

Commit

Permalink
Bring frame_objects.py into mypy compliance.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleary committed Apr 28, 2024
1 parent 740c1e5 commit aad09ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

subprocess.check_call([
'mypy',
'src/echo/frame_objects.py',
'src/echo/__init__.py',
'src/echo/import_routines.py',
'src/echo/bc_helpers.py',
Expand Down
7 changes: 5 additions & 2 deletions src/echo/frame_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def _handle_exception(self, why: WhyStatus,
if (why == WhyStatus.CONTINUE and
self.block_stack[-1].kind == BlockKind.SETUP_LOOP):
b = self.block_stack[-1]
assert isinstance(return_value, int), return_value
self.pc = return_value
return True

Expand Down Expand Up @@ -1176,7 +1177,9 @@ def _run_one_bytecode(self) -> Optional[Result[Tuple[Value, ReturnKind]]]:
return Result((v, ReturnKind.RETURN))

if instruction.opname == 'YIELD_VALUE':
self.pc += self.pc_to_bc_width[self.pc]
yield_width: Optional[int] = self.pc_to_bc_width[self.pc]
assert yield_width is not None
self.pc += yield_width
return Result((Value(self._peek()), ReturnKind.YIELD))

f = getattr(self, '_run_{}'.format(instruction.opname))
Expand Down Expand Up @@ -1268,7 +1271,7 @@ def get_dict(self):
def get_bases(self):
raise NotImplementedError

def get_mro(self) -> Tuple[EPyObject, ...]:
def get_mro(self) -> Tuple[Union[EPyType, type], ...]:
return (self,)

def get_type(self) -> EPyType:
Expand Down
5 changes: 3 additions & 2 deletions src/echo/interp_context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, Callable
from typing import Any, Callable, Optional

from echo.interpreter_state import InterpreterState
from echo.interp_result import ExceptionData


EModule = Any
Expand All @@ -20,7 +21,7 @@ def __init__(self, interp_state: InterpreterState,
interp_state.sys_modules['sys'] = esys
self.ebuiltins = ebuiltins
self.desc_count = 0
self.exc_info = None
self.exc_info: Optional[ExceptionData] = None
self.call_profiler = None

def call(self, *args, **kwargs):
Expand Down

0 comments on commit aad09ec

Please sign in to comment.