MCPcopy Index your code
hub / github.com/python/cpython / parse_import

Method parse_import

Lib/_pyrepl/_module_completer.py:355–371  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

353 return self.parse_import()
354
355 def parse_import(self) -> Result:
356 if self.code.rstrip().endswith('import') and self.code.endswith(' '):
357 return Result(name='')
358 if self.tokens.peek_string(','):
359 name = ''
360 else:
361 if self.code.endswith(' '):
362 raise ParseError('parse_import')
363 name = self.parse_dotted_name()
364 if name.startswith('.'):
365 raise ParseError('parse_import')
366 while self.tokens.peek_string(','):
367 self.tokens.pop()
368 self.parse_dotted_as_name()
369 if self.tokens.peek_string('import'):
370 return Result(name=name)
371 raise ParseError('parse_import')
372
373 def parse_from_import(self) -> Result:
374 stripped = self.code.rstrip()

Callers 1

_parseMethod · 0.95

Calls 9

parse_dotted_nameMethod · 0.95
parse_dotted_as_nameMethod · 0.95
peek_stringMethod · 0.80
ResultClass · 0.70
ParseErrorClass · 0.70
endswithMethod · 0.45
rstripMethod · 0.45
startswithMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected