Skip to content

Conversation

@chirizxc
Copy link
Contributor

@chirizxc chirizxc commented Dec 16, 2025

Summary

Fixes #21794

Test Plan

cargo nextest run flake8_use_pathlib

@chirizxc chirizxc changed the title [flake8-use-pathlib] [flake8-use-pathlib] Fix PTH's unsafe handling when return types change in compound statements Dec 16, 2025
@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 16, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +0 -26 fixes in 3 projects; 52 projects unchanged)

apache/airflow (+0 -0 violations, +0 -16 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL

- dev/breeze/src/airflow_breeze/commands/minor_release_command.py:180:17: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/minor_release_command.py:180:17: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_candidate_command.py:719:25: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/release_candidate_command.py:719:25: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_command.py:123:23: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/release_command.py:123:23: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_command.py:156:23: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/release_command.py:156:23: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_command.py:177:19: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/release_command.py:177:19: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_command.py:387:25: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/release_command.py:387:25: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_command.py:403:19: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/release_command.py:403:19: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/utils/reproducible.py:61:21: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/utils/reproducible.py:61:21: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`

bokeh/bokeh (+0 -0 violations, +0 -8 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL

- src/bokeh/application/handlers/code_runner.py:219:16: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ src/bokeh/application/handlers/code_runner.py:219:16: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- src/bokeh/util/compiler.py:246:20: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ src/bokeh/util/compiler.py:246:20: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- tests/support/util/filesystem.py:160:11: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ tests/support/util/filesystem.py:160:11: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
- tests/unit/bokeh/application/handlers/test_code_runner.py:154:19: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ tests/unit/bokeh/application/handlers/test_code_runner.py:154:19: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`

latchbio/latch (+0 -0 violations, +0 -2 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview

- src/latch_cli/snakemake/serialize.py:152:25: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
+ src/latch_cli/snakemake/serialize.py:152:25: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PTH109 26 0 0 0 26

@ntBre ntBre added fixes Related to suggested fixes for violations preview Related to preview mode features labels Dec 17, 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 for working on this! But I think we need to be a bit more careful here.

@chirizxc chirizxc requested a review from ntBre December 17, 2025 16:32
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 for the quick fix! I think the logic here is good to go, I just had one small suggestion about combining the two helper functions.

@chirizxc
Copy link
Contributor Author

Thanks for the quick fix! I think the logic here is good to go, I just had one small suggestion about combining the two helper functions.

Yes, I think it makes sense to combine them.

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.

Thank you!

@ntBre ntBre changed the title [flake8-use-pathlib] Fix PTH's unsafe handling when return types change in compound statements [flake8-use-pathlib] Make fixes unsafe when types change in compound statements (PTH104, PTH105, PTH109, PTH115) Dec 17, 2025
@ntBre ntBre merged commit 883701a into astral-sh:main Dec 17, 2025
37 checks passed
@chirizxc chirizxc deleted the issue-21483 branch December 17, 2025 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes Related to suggested fixes for violations preview Related to preview mode features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PTH fixes should be unsafe when they change return types in compound statements

2 participants