-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[semantic error tests]: refactor semantic error tests to separate files #20926
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
Conversation
|
Nice, thanks for working on this! Let me know when it's ready for review, or if you need any help. It looks like you're on the right track :) |
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
9d88226 to
ed24d8c
Compare
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
|
CI is green : ) , its ready for review. Thank you |
|
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.
Thank you! I had a few small nits, but this looks great. I think this will make these tests a lot easier to work with.
crates/ruff_linter/src/linter.rs
Outdated
| ..Default::default() | ||
| }, | ||
| ); | ||
| insta::with_settings!({filters => vec![(r"\\", "/")]}, { |
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.
Do we need this filter? It looks like we use test_contents_syntax_errors in other tests in this file without the filter, so it would probably be okay to omit it.
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.
done
crates/ruff_linter/src/linter.rs
Outdated
| }, | ||
| ); | ||
| insta::with_settings!({filters => vec![(r"\\", "/")]}, { | ||
| assert_diagnostics!(format!("{snapshot}_{python_version}"), diagnostics); |
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.
It looks like we're adding the Python version twice, once here and once above on line 1033.
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.
done
crates/ruff_linter/src/linter.rs
Outdated
| let contents = std::fs::read_to_string(&path)?; | ||
| let source_kind = SourceKind::Python(contents); | ||
| for &python_version in python_versions { | ||
| let snapshot = format!("semantic_syntax_error_{error_type}_{python_version}"); |
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.
I think we could probably omit the error_type and just use the path instead. That seems closer to what we do for lint rules, and it will make the test_case entries a bit shorter.
Looking back at the blame, I'm actually not sure why we added error_type in the first place.
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.
done
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.
path is causing windows test to fail .
crates/ruff_linter/src/linter.rs
Outdated
| PythonVersion::PY312, | ||
| "InvalidExpression" | ||
| Path::new("global_parameter.py"), | ||
| &[PythonVersion::PY312], |
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.
It looks like most of these only have one Python version, so I'd probably just pass a single Python version, like we had before. And then we can duplicate the test_case like:
#[test_case(Path::new("some_file.py"), PythonVersion::PY311)]
#[test_case(Path::new("some_file.py"), PythonVersion::PY312)]I think that looks a bit neater.
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.
done
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
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.
Thank you! I had a handful of additional naming/version nits, but I think this is good to go otherwise.
Signed-off-by: 11happy <[email protected]>
…l-constraint-sets
* dcreager/refactor-constraint-mdtests: (60 commits)
add static_asserts
move all reveal diagnostics to separate line
add more gradual tests
better comment
restructure a bit
better names/comments
simplify before implication
two typevars!
mdformat
rename mdtest
move is_subtype_of_given into ConstraintSet
move where we grab these
add ConstraintSet.{always,never}
move range_constraint into ConstraintSet class
[ty] Rename `inner` query for better debugging experience (#21106)
[ty] Add new "constraint implication" typing relation (#21010)
[semantic error tests]: refactor semantic error tests to separate files (#20926)
Respect `--output-format` with `--watch` (#21097)
[`pyflakes`] Revert to stable behavior if imports for module lie in alternate branches for `F401` (#20878)
Fix finding keyword range for clause header after statement ending with semicolon (#21067)
...
Summary
This PR refactors semantic error tests in each seperate file
Test Plan
CC