Skip to content

Conversation

@chirizxc
Copy link
Contributor

@chirizxc chirizxc commented Jul 9, 2025

Summary

Part of #2331

Test Plan

cargo nextest run flake8_use_pathlib

@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +50 -0 fixes in 4 projects; 51 projects unchanged)

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

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

+ airflow-core/src/airflow/cli/cli_config.py:178:40: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- airflow-core/src/airflow/cli/cli_config.py:178:40: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ airflow-core/tests/unit/utils/test_cli_util.py:188:38: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- airflow-core/tests/unit/utils/test_cli_util.py:188:38: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ airflow-core/tests/unit/utils/test_cli_util.py:193:37: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- airflow-core/tests/unit/utils/test_cli_util.py:193:37: 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/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:372:25: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_candidate_command.py:372:25: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/release_command.py:197:25: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_command.py:197:25: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/commands/release_command.py:213:19: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/commands/release_command.py:213:19: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/utils/docs_publisher.py:85:61: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/utils/docs_publisher.py:85:61: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/utils/reproducible.py:60:21: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/utils/reproducible.py:60:21: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ dev/breeze/src/airflow_breeze/utils/run_utils.py:132:41: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- dev/breeze/src/airflow_breeze/utils/run_utils.py:132:41: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ providers/elasticsearch/tests/unit/elasticsearch/log/test_es_task_handler.py:883:48: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- providers/elasticsearch/tests/unit/elasticsearch/log/test_es_task_handler.py:883:48: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ scripts/ci/pre_commit/common_precommit_utils.py:83:29: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- scripts/ci/pre_commit/common_precommit_utils.py:83:29: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`

apache/superset (+0 -0 violations, +2 -0 fixes)

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

+ superset/extensions/pylint.py:44:25: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- superset/extensions/pylint.py:44:25: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`

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

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

+ release/system.py:57:50: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- release/system.py:57:50: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ release/system.py:61:34: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- release/system.py:61:34: 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/application/handlers/code_runner.py:219:16: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ src/bokeh/io/export.py:527:76: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- src/bokeh/io/export.py:527:76: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ src/bokeh/io/util.py:78:36: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- src/bokeh/io/util.py:78:36: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ src/bokeh/sphinxext/util.py:48:22: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- src/bokeh/sphinxext/util.py:48:22: 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()`
+ tests/unit/bokeh/application/handlers/test_code_runner.py:159:16: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- tests/unit/bokeh/application/handlers/test_code_runner.py:159:16: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`
+ tests/unit/bokeh/util/test_browser.py:98:63: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()`
- tests/unit/bokeh/util/test_browser.py:98:63: PTH109 `os.getcwd()` should be replaced by `Path.cwd()`

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

ruff check --no-cache --exit-zero --ignore RUF9 --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 50 0 0 50 0

@chirizxc
Copy link
Contributor Author

@ntBre I'm not really sure about the behavior of

cwd = os.getcwd(
    # 1
)

when we have comments inside brackets, because I've seen this somewhere, even though the function takes no arguments it's still worth marking the autofix as unsafe

@ntBre ntBre added fixes Related to suggested fixes for violations preview Related to preview mode features labels Jul 11, 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, this looks good. We just need to validate the number of arguments before offering a fix.

when we have comments inside brackets, because I've seen this somewhere, even though the function takes no arguments it's still worth marking the autofix as unsafe

I think you made the right call making the fix unsafe, even if this is probably uncommon 👍

@chirizxc
Copy link
Contributor Author

What about os.getcwdb()? Is it worth adding an example in the documentation?

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!

What about os.getcwdb()? Is it worth adding an example in the documentation?

I think it's okay to leave out the example since it's so similar to the existing one. The ## What it does section mentions getcwdb at least.

@ntBre ntBre merged commit 5d78b31 into astral-sh:main Jul 17, 2025
35 checks passed
@chirizxc chirizxc deleted the feat/more-pth-autofixes branch July 17, 2025 14:13
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.

2 participants