-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[red-knot] Ignore surrounding whitespace when looking for <!-- snapshot-diagnostics -->
directives in mdtests
#16380
Conversation
…hot-diagnostics -->` directives in mdtests
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
|
||
while let Some(first) = self.cursor.bump() { | ||
match first { | ||
'<' => { | ||
self.explicit_path = None; | ||
self.preceding_blank_lines = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, should these have been removed? I think so, because now when this branch is taken, we either successfully parse an HTML comment (in which case, the previous state should probably be retained) or we report an error. It might be worth an added unit test for this? Although I wonder if it's actually impossible to observe. I'm thinking about something where you have
`some/file/path.py`:
<!-- snapshot-diagnostics -->
```py
print("frob")
```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yeah, good question. I think you're right, I think removing these is probably best?
I'm not entirely sure how to easily add a useful unit test for this (and doesn't seem worth spending a lot of time on), but happy to add one as a followup if you can think of something 😄
* main: [red-knot] Switch to a handwritten parser for mdtest error assertions (#16422) [red-knot] Disallow more invalid type expressions (#16427) Bump version to Ruff 0.9.9 (#16434) Check `LinterSettings::preview` for version-related syntax errors (#16429) Avoid caching files with unsupported syntax errors (#16425) Prioritize "bug" label for changelog sections (#16433) [`flake8-copyright`] Add links to applicable options (`CPY001`) (#16421) Fix string-length limit in documentation for PYI054 (#16432) Show version-related syntax errors in the playground (#16419) Allow passing `ParseOptions` to inline tests (#16357) Bump version to 0.9.8 (#16414) [red-knot] Ignore surrounding whitespace when looking for `<!-- snapshot-diagnostics -->` directives in mdtests (#16380) Notify users for invalid client settings (#16361) Avoid indexing the project if `configurationPreference` is `editorOnly` (#16381)
* dcreager/alist-type: Remove unneeded shear override Update property test CI Move alist into red_knot_python_semantic [red-knot] Switch to a handwritten parser for mdtest error assertions (#16422) [red-knot] Disallow more invalid type expressions (#16427) Bump version to Ruff 0.9.9 (#16434) Check `LinterSettings::preview` for version-related syntax errors (#16429) Avoid caching files with unsupported syntax errors (#16425) Prioritize "bug" label for changelog sections (#16433) [`flake8-copyright`] Add links to applicable options (`CPY001`) (#16421) Fix string-length limit in documentation for PYI054 (#16432) Show version-related syntax errors in the playground (#16419) Allow passing `ParseOptions` to inline tests (#16357) Bump version to 0.9.8 (#16414) [red-knot] Ignore surrounding whitespace when looking for `<!-- snapshot-diagnostics -->` directives in mdtests (#16380) Notify users for invalid client settings (#16361) Avoid indexing the project if `configurationPreference` is `editorOnly` (#16381)
Summary
Something unfortunate that happened while I was working on #16321 was that I initially added an HMTL comment like this:
...and I failed to notice for quite a while that there where no snapshots being tested for that specific test. (The directive was missing a whitespace between the
<!--
opener and the word "snapshot", meaning that mdtest wasn't recognising it as a directive.)This PR changes the parsing of these directives so that whitespace surrounding the phrase "snapshot-diagnostics" is ignored inside HTML comments.
Test Plan
I added a unit test to the
red_knot_test
crate. I also manually verified that if you apply this diff, runningcargo test -p red_knot_python_semantic
creates a new snapshot for you: