[airflow] Get rid of Replacement::Name and replace them with Replacement::AutoImport for enabling auto fixing (AIR301, AIR311)#17941
Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| AIR301 | 4 | 2 | 2 | 0 | 0 |
airflow] Get rid of Replacement::Name and replace them with Replacement::AutoImport for enabling auto fixing (AIR302, AIR312)
6c4f3dd to
4968eb0
Compare
airflow] Get rid of Replacement::Name and replace them with Replacement::AutoImport for enabling auto fixing (AIR302, AIR312)airflow] Get rid of Replacement::Name and replace them with Replacement::AutoImport for enabling auto fixing (AIR301, AIR311)
4968eb0 to
b22e94c
Compare
ntBre
left a comment
There was a problem hiding this comment.
This looks good to me, just one question!
| Replacement::AttrName(name) => Some(format!("Use `{name}` instead")), | ||
| Replacement::Message(message) => Some((*message).to_string()), |
There was a problem hiding this comment.
Do these need to be separate? It looks like all of the Replacement::Messages down below include Use ... instead in their messages, so I think you could at least combine these match arms if not the entire variants.
| Replacement::AttrName(name) => Some(format!("Use `{name}` instead")), | |
| Replacement::Message(message) => Some((*message).to_string()), | |
| Replacement::AttrName(name) | Replacement::Message(name) => Some(format!("Use `{name}` instead")), |
Or do you have plans to make the messages more different later on?
There was a problem hiding this comment.
There are one or two exceptions now. So it's still needed
ruff/crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs
Lines 717 to 719 in 8cbd433
I'm thinking of merging the message into other types later on so that we can provide extra information for them as well.
There was a problem hiding this comment.
Ah thanks, I missed that one. I'll merge this!
…lacement::AutoImport` for enabling auto fixing (`AIR301`, `AIR311`) (astral-sh#17941) <!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Similiar to astral-sh#17941. `Replacement::Name` was designed for linting only. Now, we also want to fix the user code. It would be easier to replace it with a better AutoImport struct whenever possible. On the other hand, `AIR301` and `AIR311` contain attribute changes that can still use a struct like `Replacement::Name`. To reduce the confusion, I also updated it as `Replacement::AttrName` Some of the original `Replacement::Name` has been replaced as `Replacement::Message` as they're not directly mapping and the message has now been moved to `help` ## Test Plan <!-- How was it tested? --> The test fixtures have been updated
Summary
Similiar to #17941.
Replacement::Namewas designed for linting only. Now, we also want to fix the user code. It would be easier to replace it with a better AutoImport struct whenever possible.On the other hand,
AIR301andAIR311contain attribute changes that can still use a struct likeReplacement::Name. To reduce the confusion, I also updated it asReplacement::AttrNameSome of the original
Replacement::Namehas been replaced asReplacement::Messageas they're not directly mapping and the message has now been moved tohelpTest Plan
The test fixtures have been updated