MCPcopy Index your code
hub / github.com/dropbox/pyannotate / parse

Method parse

pyannotate_tools/annotations/parse.py:228–266  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

226 self.i = 0
227
228 def parse(self):
229 # type: () -> Tuple[List[Argument], AbstractType]
230 self.expect('(')
231 arg_types = [] # type: List[Argument]
232 stars_seen = set() # type: Set[str]
233 while self.lookup() != ')':
234 if self.lookup() == '*':
235 self.expect('*')
236 if self.lookup() == '*':
237 if '**' in stars_seen:
238 self.fail()
239 self.expect('*')
240 star_star = True
241 else:
242 if stars_seen:
243 self.fail()
244 star_star = False
245 arg_type = self.parse_type()
246 if star_star:
247 arg_types.append(Argument(arg_type, ARG_STARSTAR))
248 stars_seen.add('**')
249 else:
250 arg_types.append(Argument(arg_type, ARG_STAR))
251 stars_seen.add('*')
252 else:
253 if stars_seen:
254 self.fail()
255 arg_type = self.parse_type()
256 arg_types.append(Argument(arg_type, ARG_POS))
257 if self.lookup() == ',':
258 self.expect(',')
259 elif self.lookup() == ')':
260 break
261 self.expect(')')
262 self.expect('->')
263 ret_type = self.parse_type()
264 if not isinstance(self.next(), End):
265 self.fail()
266 return arg_types, ret_type
267
268 def parse_type_list(self):
269 # type: () -> List[AbstractType]

Callers 1

parse_type_commentFunction · 0.80

Calls 6

expectMethod · 0.95
lookupMethod · 0.95
failMethod · 0.95
parse_typeMethod · 0.95
nextMethod · 0.95
addMethod · 0.80

Tested by

no test coverage detected