Skip to content

Conversation

Lee-W
Copy link
Contributor

@Lee-W Lee-W commented May 14, 2025

Summary

Add utility functions generate_import_edit and generate_remove_and_runtime_import_edit to generate the fix needed for the airflow rules.

  1. generate_import_edit is for the cases where the member name has changed. (e.g., airflow.datasts.Dataset to airflow.sdk.Asset) It's just extracted from the original logic
  2. generate_remove_and_runtime_import_edit is for cases where the member name has not changed. (e.g., airflow.operators.pig_operator.PigOperator to airflow.providers.apache.pig.hooks.pig.PigCliHook) This is newly introduced. As it introduced runtime import, I mark it as an unsafe fix. Under the hook, it tried to find the original import statement, remove it, and add a new import fix

  • rules fix
    • airflow.sensors.external_task_sensor.ExternalTaskSensorLinkairflow.providers.standard.sensors.external_task.ExternalDagLink

Test Plan

The existing test fixtures have been updated

@Lee-W Lee-W force-pushed the improve-autofix-to-AIR302 branch 3 times, most recently from fe83dee to 6938e72 Compare May 20, 2025 08:54
Copy link
Contributor

github-actions bot commented May 20, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@Lee-W Lee-W force-pushed the improve-autofix-to-AIR302 branch from 6938e72 to 1b900fe Compare May 20, 2025 09:27
@Lee-W Lee-W changed the title Improve autofix to air302 [airflow] Add unsafe fix module moved cases (AIR302) May 20, 2025
@Lee-W Lee-W force-pushed the improve-autofix-to-AIR302 branch from 1b900fe to deb0476 Compare May 20, 2025 09:37
@Lee-W Lee-W marked this pull request as ready for review May 20, 2025 10:02
@Lee-W Lee-W mentioned this pull request May 20, 2025
2 tasks
@Lee-W Lee-W force-pushed the improve-autofix-to-AIR302 branch from cb45fa0 to f6f7bd1 Compare May 27, 2025 14:33
@Lee-W
Copy link
Contributor Author

Lee-W commented May 27, 2025

@ntBre Didn't notice another PR was merged 🤦‍♂️ Just rebased and fix this PR! If the idea looks good, I'm going to apply it to other rules. Thanks!

@ntBre
Copy link
Contributor

ntBre commented May 28, 2025

It looks like one of my PRs today caused another conflict. I was going to fix it and push here for you, but it looks like I can't edit the branch. I think you can see the diff here if it helps.

I'll go ahead and take a look now anyway.

@ntBre ntBre added rule Implementing or modifying a lint rule preview Related to preview mode features labels May 28, 2025
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I didn't review all of the snaps in depth, but this makes sense to me. Just a couple of suggestions and the merge conflicts and then this is good to go.

@Lee-W Lee-W force-pushed the improve-autofix-to-AIR302 branch from f6f7bd1 to 6afbe90 Compare May 29, 2025 08:19
@ntBre ntBre merged commit 3445d13 into astral-sh:main May 29, 2025
34 checks passed
ntBre pushed a commit that referenced this pull request May 30, 2025
<!--
Thank you for contributing to Ruff/ty! 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? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

Follow up on #18093 and apply it
to AIR301

## Test Plan

<!-- How was it tested? -->

The existing test fixtures have been updated
ntBre pushed a commit that referenced this pull request May 30, 2025
<!--
Thank you for contributing to Ruff/ty! 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? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

Follow up on #18093 and apply it
to AIR311

---

Rules fixed
* `airflow.models.datasets.expand_alias_to_datasets` →
`airflow.models.asset.expand_alias_to_assets`
* `airflow.models.baseoperatorlink.BaseOperatorLink` →
`airflow.sdk.BaseOperatorLink`


## Test Plan

<!-- How was it tested? -->
The existing test fixtures have been updated
ntBre pushed a commit that referenced this pull request May 30, 2025
<!--
Thank you for contributing to Ruff/ty! 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? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

Follow up on #18093 and apply it
to AIR312

## Test Plan

<!-- How was it tested? -->

The existing test fixtures have been updated
dcreager added a commit that referenced this pull request May 30, 2025
* main:
  [ty] support callability of bound/constrained typevars (#18389)
  [ty] Minor tweaks to "list all members" docs and tests (#18388)
  [ty] Fix broken property tests for disjointness (#18384)
  [ty] List available members for a given type (#18251)
  [`airflow`] Add unsafe fix for module moved cases (`AIR312`) (#18363)
  Add a `SourceFile` to `OldDiagnostic` (#18356)
  Update salsa past generational id change (#18362)
  [`airflow`] Add unsafe fix for module moved cases (`AIR311`) (#18366)
  [`airflow`] Add unsafe fix for module moved cases (`AIR301`) (#18367)
  [ty] Improve tests for `site-packages` discovery (#18374)
  [ty] _typeshed.Self is not a special form (#18377)
  [ty] Callable types are disjoint from non-callable `@final` nominal instance types (#18368)
  [ty] Add diagnosis for function with no return statement but with return type annotation (#18359)
  [`airflow`] Add unsafe fix module moved cases (`AIR302`) (#18093)
  Rename `ruff_linter::Diagnostic` to `OldDiagnostic` (#18355)
  [`refurb`] Add coverage of `set` and `frozenset` calls (`FURB171`) (#18035)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants