[airflow] Skip attribute check in try catch block (AIR301)#17790
[airflow] Skip attribute check in try catch block (AIR301)#17790ntBre merged 1 commit intoastral-sh:mainfrom
airflow] Skip attribute check in try catch block (AIR301)#17790Conversation
|
c3bb041 to
aca897d
Compare
| /// member is being accessed from the non-deprecated location? | ||
| fn try_block_contains_undeprecated_attribute( | ||
| try_node: &StmtTry, | ||
| replacement: &Replacement, |
There was a problem hiding this comment.
If I want to apply it to ProviderReplacement and other types, is there a smarter way to do so?
There was a problem hiding this comment.
Do you mean pass ProviderReplacement to this function instead of Replacement? In that case, I see two options:
- Make the function generic and introduce some kind of
Replacementtrait:fn try_block_contains_undeprecated_attribute<T: Replacement>( try_node: &StmtTry, replacement: &T, semantic: &SemanticModel, ) -> bool { /* ... */ } trait Replacement { fn module(&self) -> &str; fn name(&self) -> &str; }
- Pass
moduleandnamedirectly to the function:fn try_block_contains_undeprecated_attribute( try_node: &StmtTry, module: &str, name: &str, semantic: &SemanticModel, ) -> bool { /* ... */ }
These both assume that you just need module and name from the Replacement types, but that seems to be the case. I think the second option is a bit easier if there are only a few fields. A trait is probably overkill.
aca897d to
dceaf92
Compare
ntBre
left a comment
There was a problem hiding this comment.
Thanks, this looks good to me! Is this good to merge, or do you want to resolve your question about ProviderReplacement first?
| /// member is being accessed from the non-deprecated location? | ||
| fn try_block_contains_undeprecated_attribute( | ||
| try_node: &StmtTry, | ||
| replacement: &Replacement, |
There was a problem hiding this comment.
Do you mean pass ProviderReplacement to this function instead of Replacement? In that case, I see two options:
- Make the function generic and introduce some kind of
Replacementtrait:fn try_block_contains_undeprecated_attribute<T: Replacement>( try_node: &StmtTry, replacement: &T, semantic: &SemanticModel, ) -> bool { /* ... */ } trait Replacement { fn module(&self) -> &str; fn name(&self) -> &str; }
- Pass
moduleandnamedirectly to the function:fn try_block_contains_undeprecated_attribute( try_node: &StmtTry, module: &str, name: &str, semantic: &SemanticModel, ) -> bool { /* ... */ }
These both assume that you just need module and name from the Replacement types, but that seems to be the case. I think the second option is a bit easier if there are only a few fields. A trait is probably overkill.
Would be nice if we could merge it first and I'll spend some time figure that out tomorrow 🙂 Thanks for the suggestions! |
<!-- 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? --> Skip attribute check in try catch block (`AIR301`) ## Test Plan <!-- How was it tested? --> update `crates/ruff_linter/resources/test/fixtures/airflow/AIR301_names_try.py`
…l-sh#17790) <!-- 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? --> Skip attribute check in try catch block (`AIR301`) ## Test Plan <!-- How was it tested? --> update `crates/ruff_linter/resources/test/fixtures/airflow/AIR301_names_try.py`
Summary
Skip attribute check in try catch block (
AIR301)Test Plan
update
crates/ruff_linter/resources/test/fixtures/airflow/AIR301_names_try.py