Skip to content

Commit

Permalink
fix types generated by typerwriter
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenfreund committed Apr 8, 2024
1 parent 80055cf commit 8eae6b9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/chatdbg/pdb_util/locals.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ class SymbolFinder(ast.NodeVisitor):
def __init__(self):
self.defined_symbols = set()

def visit_Assign(self, node):
def visit_Assign(self, node: ast.Assign) -> None:
for target in node.targets:
if isinstance(target, ast.Name):
self.defined_symbols.add(target.id)
self.generic_visit(node)

def visit_For(self, node):
def visit_For(self, node: ast.For) -> None:
if isinstance(node.target, ast.Name):
self.defined_symbols.add(node.target.id)
self.generic_visit(node)

def visit_comprehension(self, node):
def visit_comprehension(self, node: ast.Name) -> None:
if isinstance(node.target, ast.Name):
self.defined_symbols.add(node.target.id)
self.generic_visit(node)
Expand All @@ -50,7 +50,7 @@ def _extract_locals(frame: FrameType) -> Set[str]:
return set()


def _extract_nb_globals(globals):
def _extract_nb_globals(globals: Dict[str, Any]):
result = set()
for source in globals["In"]:
try:
Expand All @@ -63,15 +63,15 @@ def _extract_nb_globals(globals):
return result


def _is_iterable(obj: Union[Any, List[str], List[Any]]) -> bool: # FIXME
def _is_iterable(obj: Any) -> bool:
try:
iter(obj)
return True
except TypeError:
return False


def _repr_if_defined(obj: Union[Any, List[str], List[Any]]) -> bool: # FIXME
def _repr_if_defined(obj: Any) -> bool:
if obj.__class__ in [np.ndarray, dict, list, tuple]:
# handle these at iterables to truncate reasonably
return False
Expand All @@ -82,9 +82,7 @@ def _repr_if_defined(obj: Union[Any, List[str], List[Any]]) -> bool: # FIXME
return result


def _format_limited(
value: Union[np.ndarray, int], limit: int = 10, depth: int = 3
) -> str:
def _format_limited(value: Any, limit: int = 10, depth: int = 3) -> str:
def format_tuple(t, depth):
return tuple([helper(x, depth) for x in t])

Expand Down

0 comments on commit 8eae6b9

Please sign in to comment.