Skip to content

Allowing sys.stind.readline receive size parameter #960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
adding annotations and removing else statement
  • Loading branch information
ulisesojeda committed May 28, 2022
commit bb236599599d74e702aa711d02a69fb24b24002c
13 changes: 6 additions & 7 deletions bpython/curtsiesfrontend/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,18 @@ def add_input_character(self, e: str) -> None:
)
self.cursor_offset += 1

def readline(self, size=-1):
def readline(self, size: int = -1) -> str:
if not isinstance(size, int):
raise TypeError(
f"'{type(size).__name__}' object cannot be interpreted as an integer"
)
elif size == 0:
return ""
else:
self.has_focus = True
self.repl.send_to_stdin(self.current_line)
value = self.coderunner.request_from_main_context()
self.readline_results.append(value)
return value if size <= -1 else value[:size]
self.has_focus = True
self.repl.send_to_stdin(self.current_line)
value = self.coderunner.request_from_main_context()
self.readline_results.append(value)
return value if size <= -1 else value[:size]

def readlines(self, size=-1):
return list(iter(self.readline, ""))
Expand Down