Skip to content
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
Avoid calling rstrip more than once
  • Loading branch information
tomasr8 committed Apr 19, 2025
commit 10da15b3b1509333a296663ac54a7a8822945664
5 changes: 3 additions & 2 deletions Lib/_pyrepl/_module_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,10 @@ def parse_import(self) -> Result:
raise ParseError('parse_import')

def parse_from_import(self) -> Result:
if self.code.rstrip().endswith('import') and self.code.endswith(' '):
stripped = self.code.rstrip()
if stripped.endswith('import') and self.code.endswith(' '):
return Result(from_name=self.parse_empty_from_import(), name='')
if self.code.rstrip().endswith('from') and self.code.endswith(' '):
if stripped.endswith('from') and self.code.endswith(' '):
return Result(from_name='')
if self.tokens.peek_string('(') or self.tokens.peek_string(','):
return Result(from_name=self.parse_empty_from_import(), name='')
Expand Down