[async-function-with-timeout] Disable check for asyncio before Python 3.11 (ASYNC109)#13023
[async-function-with-timeout] Disable check for asyncio before Python 3.11 (ASYNC109)#13023MichaReiser merged 3 commits intoastral-sh:mainfrom
Conversation
…ython3.11 (ASYNC109)
CodSpeed Performance ReportMerging #13023 will improve performances by 10.62%Comparing Summary
Benchmarks breakdown
|
|
|
Thanks. This does make sense to me. However, it does mean that the rule now deviates from the upstream rule (I'm not sure if It would be great if we can add a test demonstrating that this is working as expected (flags asyncio but not anyio) You can add the test here ruff/crates/ruff_linter/src/rules/flake8_async/mod.rs Lines 18 to 39 in 45f459b and you can use the code below (you have to change the path to the python file) #[test]
fn async109_python_310_or_odler() -> Result<()> {
let diagnostics = test_path(
Path::new("flake8_async").join("path_to_test_File"),
&LinterSettings {
target_version: PythonVersion::Py310,
..LinterSettings::for_rule(Rule::AsyncFunctionWithTimeout)
},
)?;
assert_messages!(diagnostics);
Ok(())
} |
Yeah, this change definitely makes sense to me! There are third-party libraries backporting |
MichaReiser
left a comment
There was a problem hiding this comment.
Perfect. Let's add a test and then merge this
Some (occasionally tangential) discussion is found here: #12353
Summary
Before, the diagnostic was raised for all supported versions of Python. However,
asyncioonly introducedasyncio.timeoutin python version 3.11.Now, the diagnostic is not raised when using
asynciowith Python versions before 3.11Test Plan
It's a policy tweak leveraging well-tested library features. I don't see an obvious need for an additional test, but I would be happy to receive guidance on how to add a test.