summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index e8068f2..5dc2ae6 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1272,14 +1272,11 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
type_start = p;
- is_type_ignore = tok->cur >= p + 6 && memcmp(p, "ignore", 6) == 0;
- p += 6;
- while (is_type_ignore && p < tok->cur) {
- if (*p == '#')
- break;
- is_type_ignore = is_type_ignore && (*p == ' ' || *p == '\t');
- p++;
- }
+ /* A TYPE_IGNORE is "type: ignore" followed by the end of the token
+ * or anything non-alphanumeric. */
+ is_type_ignore = (
+ tok->cur >= p + 6 && memcmp(p, "ignore", 6) == 0
+ && !(tok->cur > p + 6 && isalnum(p[6])));
if (is_type_ignore) {
/* If this type ignore is the only thing on the line, consume the newline also. */