Skip to content

Commit 10da15b

Browse files
committed
Avoid calling rstrip more than once
1 parent 5c11124 commit 10da15b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/_pyrepl/_module_completer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ def parse_import(self) -> Result:
223223
raise ParseError('parse_import')
224224

225225
def parse_from_import(self) -> Result:
226-
if self.code.rstrip().endswith('import') and self.code.endswith(' '):
226+
stripped = self.code.rstrip()
227+
if stripped.endswith('import') and self.code.endswith(' '):
227228
return Result(from_name=self.parse_empty_from_import(), name='')
228-
if self.code.rstrip().endswith('from') and self.code.endswith(' '):
229+
if stripped.endswith('from') and self.code.endswith(' '):
229230
return Result(from_name='')
230231
if self.tokens.peek_string('(') or self.tokens.peek_string(','):
231232
return Result(from_name=self.parse_empty_from_import(), name='')

0 commit comments

Comments
 (0)