Skip to content

Conversation

@chirizxc
Copy link
Contributor

@chirizxc chirizxc commented Sep 3, 2025

Summary

Fixes #20214

Test Plan

@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

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

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

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

- airflow-core/src/airflow/cli/commands/info_command.py:73:21: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/src/airflow/cli/commands/info_command.py:73:21: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/src/airflow/config_templates/airflow_local_settings.py:48:24: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/src/airflow/config_templates/airflow_local_settings.py:48:24: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/src/airflow/configuration.py:124:24: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/src/airflow/configuration.py:124:24: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/src/airflow/settings.py:105:20: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/src/airflow/settings.py:105:20: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/src/airflow/settings.py:245:19: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/src/airflow/settings.py:245:19: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/src/airflow/utils/cli.py:226:34: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/src/airflow/utils/cli.py:226:34: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/src/airflow/utils/log/file_processor_handler.py:49:24: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/src/airflow/utils/log/file_processor_handler.py:49:24: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/src/airflow/utils/serve_logs/log_server.py:117:21: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/src/airflow/utils/serve_logs/log_server.py:117:21: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/tests/unit/cli/commands/test_info_command.py:49:21: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/tests/unit/cli/commands/test_info_command.py:49:21: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-core/tests/unit/core/test_configuration.py:58:12: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-core/tests/unit/core/test_configuration.py:58:12: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-ctl/src/airflowctl/api/client.py:132:61: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-ctl/src/airflowctl/api/client.py:132:61: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-ctl/src/airflowctl/api/client.py:147:61: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-ctl/src/airflowctl/api/client.py:147:61: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-ctl/tests/airflow_ctl/api/test_client.py:117:53: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-ctl/tests/airflow_ctl/api/test_client.py:117:53: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-ctl/tests/airflow_ctl/api/test_client.py:137:53: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-ctl/tests/airflow_ctl/api/test_client.py:137:53: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- airflow-ctl/tests/airflow_ctl/api/test_client.py:159:53: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ airflow-ctl/tests/airflow_ctl/api/test_client.py:159:53: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- dev/breeze/src/airflow_breeze/commands/ci_commands.py:100:17: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ dev/breeze/src/airflow_breeze/commands/ci_commands.py:100:17: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- devel-common/src/sphinx_exts/sphinx_script_update.py:51:16: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ devel-common/src/sphinx_exts/sphinx_script_update.py:51:16: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- devel-common/src/sphinx_exts/sphinx_script_update.py:53:44: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
... 17 additional changes omitted for project

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

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

- superset/config.py:99:16: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ superset/config.py:99:16: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`

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

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

- src/bokeh/command/util.py:117:28: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ src/bokeh/command/util.py:117:28: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- src/bokeh/io/export.py:131:20: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ src/bokeh/io/export.py:131:20: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- src/bokeh/io/saving.py:99:20: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ src/bokeh/io/saving.py:99:20: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- src/bokeh/settings.py:513:10: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ src/bokeh/settings.py:513:10: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`

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

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

- src/latch_cli/centromere/utils.py:133:46: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ src/latch_cli/centromere/utils.py:133:46: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`

zulip/zulip (+0 -0 violations, +0 -10 fixes)

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

- tools/droplets/add_mentor.py:50:23: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ tools/droplets/add_mentor.py:50:23: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- tools/lib/provision_inner.py:123:26: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ tools/lib/provision_inner.py:123:26: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- tools/lib/provision_inner.py:165:9: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ tools/lib/provision_inner.py:165:9: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- zerver/management/commands/export.py:146:43: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ zerver/management/commands/export.py:146:43: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
- zerver/management/commands/import.py:96:37: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()`
+ zerver/management/commands/import.py:96:37: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PTH111 74 0 0 0 74

@dscorbett
Copy link

dscorbett commented Sep 5, 2025

Apparently, it’s not uncommon for os.path.expanduser to be called on a string literal that doesn’t start with "~", in which case the PTH111 fix changes a (probably unintended) no-op into a guaranteed error. Should the fix be suppressed or changed in that case? This is not true.

@chirizxc
Copy link
Contributor Author

chirizxc commented Sep 5, 2025

Apparently, it’s not uncommon for os.path.expanduser to be called on a string literal that doesn’t start with "~", in which case the PTH111 fix changes a (probably unintended) no-op into a guaranteed error. Should the fix be suppressed or changed in that case?

I think in that case it's better to offer only diagnostic

@chirizxc chirizxc marked this pull request as draft September 5, 2025 16:12
@eli-schwartz
Copy link
Contributor

Apparently, it’s not uncommon for os.path.expanduser to be called on a string literal that doesn’t start with "~", in which case the PTH111 fix changes a (probably unintended) no-op into a guaranteed error. Should the fix be suppressed or changed in that case?

It which?

>>> pathlib.Path('.').expanduser()
PosixPath('.')

There's nothing to catch unless a genuine ~ exists.

@ntBre
Copy link
Contributor

ntBre commented Sep 17, 2025

@chirizxc is this ready for review? It sounds like the ~ question is resolved, so I think it's still fine just to mark the fix as unsafe.

@chirizxc
Copy link
Contributor Author

@chirizxc is this ready for review? It sounds like the ~ question is resolved, so I think it's still fine just to mark the fix as unsafe.

yes

@chirizxc chirizxc marked this pull request as ready for review September 17, 2025 14:19
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! Just a couple of minor suggestions.

@ntBre ntBre added fixes Related to suggested fixes for violations preview Related to preview mode features labels Sep 17, 2025
@ntBre ntBre merged commit c585c9f into astral-sh:main Sep 17, 2025
35 checks passed
@chirizxc chirizxc deleted the pth111 branch September 17, 2025 15:24
ntBre pushed a commit that referenced this pull request Sep 17, 2025
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.

os-path-expanduser (PTH111) should be marked unsafe

4 participants