Skip to content

Commit 1ad2ba4

Browse files
disallow untyped calls in autocomplete.py
1 parent 55e482a commit 1ad2ba4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

bpython/autocomplete.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
# To gradually migrate to mypy we aren't setting these globally yet
2525
# mypy: disallow_untyped_defs=True
26+
# mypy: disallow_untyped_calls=True
2627

2728
import __main__
2829
import abc

bpython/inspection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def get_encoding_file(fname):
347347
return "utf8"
348348

349349

350-
def getattr_safe(obj, name):
350+
def getattr_safe(obj: Any, name: str):
351351
"""side effect free getattr (calls getattr_static)."""
352352
result = inspect.getattr_static(obj, name)
353353
# Slots are a MemberDescriptorType
@@ -356,7 +356,7 @@ def getattr_safe(obj, name):
356356
return result
357357

358358

359-
def hasattr_safe(obj, name):
359+
def hasattr_safe(obj: Any, name: str) -> bool:
360360
try:
361361
getattr_safe(obj, name)
362362
return True

bpython/simpleeval.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import ast
2929
import sys
3030
import builtins
31+
from typing import Dict, Any
3132

3233
from . import line as line_properties
3334
from .inspection import getattr_safe
@@ -44,7 +45,7 @@ class EvaluationError(Exception):
4445
"""Raised if an exception occurred in safe_eval."""
4546

4647

47-
def safe_eval(expr, namespace):
48+
def safe_eval(expr: str, namespace: Dict[str, Any]) -> Any:
4849
"""Not all that safe, just catches some errors"""
4950
try:
5051
return eval(expr, namespace)
@@ -214,7 +215,9 @@ def find_attribute_with_name(node, name):
214215
return r
215216

216217

217-
def evaluate_current_expression(cursor_offset, line, namespace=None):
218+
def evaluate_current_expression(
219+
cursor_offset: int, line: str, namespace: Dict[str, Any] = None
220+
):
218221
"""
219222
Return evaluated expression to the right of the dot of current attribute.
220223

0 commit comments

Comments
 (0)