-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Improve autofix to air302 #18093
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
base: main
Are you sure you want to change the base?
Improve autofix to air302 #18093
Conversation
let head = match_head(expr); | ||
let binding = checker | ||
.semantic() | ||
.resolve_name(head.expect("")) |
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.
Hey @ntBre , I managed to put up a somewhat work version, but have a quick question. Is there a better way or correct way we can get rid of these expect?
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 guess it depends a bit on what could cause them to fail. I haven't really looked closely enough at match_head
to see how they can fail. Just in general, you might be able to use diagnostic.try_set_optional_fix
here, and you can return Ok(None)
instead of calling unwrap
or expect
. Something like this:
let head = match_head(expr) else {
return Ok(None);
};
That's probably the approach I would take if the result of match_head
is truly optional. If it's an error you want logged, you could instead return an anyhow::Result
from match_head
and just use ?
here.
(The main benefit of try_set_fix
is that it logs any errors that occur in the closure.)
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.
Oh I see now that there are other unwrap
/expect
calls below. You may just want to factor out another function returning an Option<Fix>
(or another type if Fix
isn't right) and only call diagnostic.try_set_fix
if it returns Some
:
if let Some(fix) = new_fix_generating_function(/* args */) {
diagnostic.try_set_fix(|| /* more code finalizing the fix */);
}
Then in new_fix_generating_function
you can use ?
anywhere you'd otherwise call unwrap or expect.
… and replace them as ProviderName::AutoImport
… compatibility was not added for some cases. Thus, the following rules are moved back to AIR302 airflow.hooks.subprocess.SubprocessResult → airflow.providers.standard.hooks.subprocess.SubprocessResult airflow.hooks.subprocess.working_directory → airflow.providers.standard.hooks.subprocess.working_directory airflow.operators.datetime.target_times_as_dates → airflow.providers.standard.operators.datetime.target_times_as_dates airflow.operators.trigger_dagrun.TriggerDagRunLink → airflow.providers.standard.operators.trigger_dagrun.TriggerDagRunLink airflow.sensors.external_task.ExternalTaskSensorLink → airflow.providers.standard.sensors.external_task.ExternalDagLink (This one contains a minor change) airflow.sensors.time_delta.WaitSensor → airflow.providers.standard.sensors.time_delta.WaitSensor
1ba8b6b
to
8860397
Compare
Summary
Test Plan