Indicate whether an input line has (i.e. ends in, or is) a comment. This uses tokenize, so it can distinguish comments from # inside strings. Parameters ---------- src : string A single line input string. Returns ------- comment : bool True if source has
(src)
| 305 | return toktypes |
| 306 | |
| 307 | def has_comment(src): |
| 308 | """Indicate whether an input line has (i.e. ends in, or is) a comment. |
| 309 | |
| 310 | This uses tokenize, so it can distinguish comments from # inside strings. |
| 311 | |
| 312 | Parameters |
| 313 | ---------- |
| 314 | src : string |
| 315 | A single line input string. |
| 316 | |
| 317 | Returns |
| 318 | ------- |
| 319 | comment : bool |
| 320 | True if source has a comment. |
| 321 | """ |
| 322 | return (tokenize.COMMENT in _line_tokens(src)) |
| 323 | |
| 324 | def ends_in_comment_or_string(src): |
| 325 | """Indicates whether or not an input line ends in a comment or within |
no test coverage detected