133 "D231", "D232", "D234r", "D234y", "D235r", "D235y", "D236", "D237", |
132 "D231", "D232", "D234r", "D234y", "D235r", "D235y", "D236", "D237", |
134 "D238", "D239", |
133 "D238", "D239", |
135 "D242", "D243", "D244", "D245", "D246", "D247", |
134 "D242", "D243", "D244", "D245", "D246", "D247", |
136 "D250", "D251", "D252", "D253", |
135 "D250", "D251", "D252", "D253", |
137 "D260", "D261", "D262", "D263", |
136 "D260", "D261", "D262", "D263", |
138 |
|
139 "D901", |
|
140 ] |
137 ] |
141 |
138 |
142 def __init__(self, source, filename, select, ignore, expected, repeat, |
139 def __init__(self, source, filename, select, ignore, expected, repeat, |
143 maxLineLength=79, docType="pep257"): |
140 maxLineLength=79, docType="pep257"): |
144 """ |
141 """ |
305 "code": code, |
302 "code": code, |
306 "args": args, |
303 "args": args, |
307 } |
304 } |
308 ) |
305 ) |
309 |
306 |
310 def __reportInvalidSyntax(self): |
|
311 """ |
|
312 Private method to report a syntax error. |
|
313 """ |
|
314 exc_type, exc = sys.exc_info()[:2] |
|
315 if len(exc.args) > 1: |
|
316 offset = exc.args[1] |
|
317 if len(offset) > 2: |
|
318 offset = offset[1:3] |
|
319 else: |
|
320 offset = (1, 0) |
|
321 self.__error(offset[0] - 1, offset[1] or 0, |
|
322 'D901', exc_type.__name__, exc.args[0]) |
|
323 |
|
324 def __resetReadline(self): |
307 def __resetReadline(self): |
325 """ |
308 """ |
326 Private method to reset the internal readline function. |
309 Private method to reset the internal readline function. |
327 """ |
310 """ |
328 self.__lineNumber = 0 |
311 self.__lineNumber = 0 |
347 # don't do anything, if essential data is missing |
330 # don't do anything, if essential data is missing |
348 return |
331 return |
349 |
332 |
350 if not self.__checkers: |
333 if not self.__checkers: |
351 # don't do anything, if no codes were selected |
334 # don't do anything, if no codes were selected |
352 return |
|
353 |
|
354 try: |
|
355 ast.parse("".join(self.__source), self.__filename) |
|
356 except (SyntaxError, TypeError): |
|
357 self.__reportInvalidSyntax() |
|
358 return |
335 return |
359 |
336 |
360 for keyword in self.__keywords: |
337 for keyword in self.__keywords: |
361 if keyword in self.__checkers: |
338 if keyword in self.__checkers: |
362 for check in self.__checkers[keyword]: |
339 for check in self.__checkers[keyword]: |