Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions bpython/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,6 @@ def get_args(self):
if inspect.isclass(f):
class_f = None

if hasattr(f, "__init__") and f.__init__ is not object.__init__:
class_f = f.__init__
if (
(not class_f or not inspection.getfuncprops(func, class_f))
and hasattr(f, "__new__")
Expand Down
28 changes: 28 additions & 0 deletions bpython/test/test_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,34 @@ def test_paremeter_name_completion(self):
self.repl.matches_iter.matches, ["abc=", "abd=", "abs("]
)

def test_parameter_advanced_on_class(self):
self.repl = FakeRepl(
{"autocomplete_mode": autocomplete.AutocompleteModes.SIMPLE}
)
self.set_input_line("TestCls(app")

code = """
import inspect

class TestCls:
# A class with boring __init__ typing
def __init__(self, *args, **kwargs):
pass
# But that uses super exotic typings recognized by inspect.signature
__signature__ = inspect.Signature([
inspect.Parameter("apple", inspect.Parameter.POSITIONAL_ONLY),
inspect.Parameter("apple2", inspect.Parameter.KEYWORD_ONLY),
inspect.Parameter("pinetree", inspect.Parameter.KEYWORD_ONLY),
])
"""
for line in code.split("\n"):
print(line[8:])
self.repl.push(line[8:])

self.assertTrue(self.repl.complete())
self.assertTrue(hasattr(self.repl.matches_iter, "matches"))
self.assertEqual(self.repl.matches_iter.matches, ["apple2=", "apple="])


class TestCliRepl(unittest.TestCase):
def setUp(self):
Expand Down