[pyflakes] [ty] Fix false positives for __annotate__ (Py3.14+) and __warningregistry__ (F821) by danparizher · Pull Request #20154 · astral-sh/ruff (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be testing what the test name suggests. As the comment says, the flakes test runner uses the latest version, which is still 3.13, so we'll need to write some custom test code here. We've been talking about switching this whole module over to the more common test_path and assert_diagnostics tests like most other rules, so I'd probably suggest just doing something like that here. One example of that:
| #[test_case(Rule::InvalidRuleCode, Path::new("RUF102.py"))] |
|---|
| fn rules(rule_code: Rule, path: &Path) -> Result<()> { |
| let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); |
| let diagnostics = test_path( |
| Path::new("ruff").join(path).as_path(), |
| &settings::LinterSettings::for_rule(rule_code), |
| )?; |
| assert_diagnostics!(snapshot, diagnostics); |
| Ok(()) |
| } |
We should also test that __annotate__ is not available before 3.14. I think this test should actually be failing given the version being used.