Fixed regular expression for # type: ignore and # pyright: ignore comments. This addresses #8000.

This commit is contained in:
Eric Traut 2024-05-25 09:30:05 -07:00
parent c1b5bccca0
commit a4d165ec02

View File

@ -1280,7 +1280,7 @@ export class Tokenizer {
const length = this._cs.position - start;
const comment = Comment.create(start, length, this._cs.getText().slice(start, start + length));
const typeIgnoreRegexMatch = comment.value.match(/((^|#)\s*)type:\s*ignore(\s*\[([\s*\w-,]*)\]|\s|$)/);
const typeIgnoreRegexMatch = comment.value.match(/((^|#)\s*)type:\s*ignore(\s*\[([\s\w-,]*)\]|\s|$)/);
if (typeIgnoreRegexMatch) {
const commentStart = start + (typeIgnoreRegexMatch.index ?? 0);
const textRange: TextRange = {
@ -1299,7 +1299,7 @@ export class Tokenizer {
}
}
const pyrightIgnoreRegexMatch = comment.value.match(/((^|#)\s*)pyright:\s*ignore(\s*\[([\s*\w-,]*)\]|\s|$)/);
const pyrightIgnoreRegexMatch = comment.value.match(/((^|#)\s*)pyright:\s*ignore(\s*\[([\s\w-,]*)\]|\s|$)/);
if (pyrightIgnoreRegexMatch) {
const commentStart = start + (pyrightIgnoreRegexMatch.index ?? 0);
const textRange: TextRange = {