Helper for has_comment and ends_in_comment_or_string.
(line)
| 290 | _MULTILINE_STRUCTURE = object() |
| 291 | |
| 292 | def _line_tokens(line): |
| 293 | """Helper for has_comment and ends_in_comment_or_string.""" |
| 294 | readline = StringIO(line).readline |
| 295 | toktypes = set() |
| 296 | try: |
| 297 | for t in generate_tokens(readline): |
| 298 | toktypes.add(t[0]) |
| 299 | except TokenError as e: |
| 300 | # There are only two cases where a TokenError is raised. |
| 301 | if 'multi-line string' in e.args[0]: |
| 302 | toktypes.add(_MULTILINE_STRING) |
| 303 | else: |
| 304 | toktypes.add(_MULTILINE_STRUCTURE) |
| 305 | return toktypes |
| 306 | |
| 307 | def has_comment(src): |
| 308 | """Indicate whether an input line has (i.e. ends in, or is) a comment. |
no test coverage detected