Fixed FrameType hinting

This commit is contained in:
GodSaveTheDoge 2021-05-11 22:15:36 +02:00
parent 1ce807012a
commit f3180eb124
1 changed files with 4 additions and 5 deletions

View File

@ -2,16 +2,15 @@ import sys
from collections import defaultdict from collections import defaultdict
from typing import Dict, Callable, List, Final from typing import Dict, Callable, List, Final
from dataclasses import dataclass from dataclasses import dataclass
from types import FrameType
FRAMETYPE = object
@dataclass @dataclass
class ConstantValue: class ConstantValue:
frame: FRAMETYPE # FIXME frame: FrameType
name: str name: str
value: object value: object
def _traceFun(frame: FRAMETYPE, event: str, arg: object) -> None: # FIXME def _traceFun(frame: FrameType, event: str, arg: object) -> None: # FIXME
for constant in constMap[frame]: for constant in constMap[frame]:
if constant.name in frame.f_locals and frame.f_locals[constant.name] != constant.value: if constant.name in frame.f_locals and frame.f_locals[constant.name] != constant.value:
frame.f_locals[constant.name] = constant.value frame.f_locals[constant.name] = constant.value
@ -28,6 +27,6 @@ class _ConstClass:
constMap[targetFrame].append(ConstantValue(targetFrame, name, value)) constMap[targetFrame].append(ConstantValue(targetFrame, name, value))
constMap: Dict[FRAMETYPE, List[ConstantValue]] = defaultdict(list) # FIXME constMap: Dict[FrameType, List[ConstantValue]] = defaultdict(list) # FIXME
sys.settrace(lambda frame, event, arg: None) sys.settrace(lambda frame, event, arg: None)
const = _ConstClass() const = _ConstClass()