Skip to content

Conversation

@chirizxc
Copy link
Contributor

@chirizxc chirizxc commented Sep 22, 2025

Summary

Part of PTH-* fixes: #19404 (comment)

Test Plan

cargo nextest run furb

@github-actions
Copy link
Contributor

github-actions bot commented Sep 22, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +840 -0 fixes in 10 projects; 45 projects unchanged)

DisnakeDev/disnake (+0 -0 violations, +10 -0 fixes)

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

+ disnake/__main__.py:293:14: FURB103 [*] `open` and `write` should be replaced by `Path(str(new_directory / "config.py"))....`
- disnake/__main__.py:293:14: FURB103 `open` and `write` should be replaced by `Path(str(new_directory / "config.py"))....`
+ disnake/__main__.py:312:18: FURB103 [*] `open` and `write` should be replaced by `Path(str(new_directory / ".gitignore")).write_text(_gitignore_template, encoding="utf-8")`
- disnake/__main__.py:312:18: FURB103 `open` and `write` should be replaced by `Path(str(new_directory / ".gitignore")).write_text(_gitignore_template, encoding="utf-8")`
+ docs/conf.py:112:6: FURB101 [*] `open` and `read` should be replaced by `Path("../disnake/__init__.py").read_text()`
- docs/conf.py:112:6: FURB101 `open` and `read` should be replaced by `Path("../disnake/__init__.py").read_text()`
+ scripts/codemods/base.py:51:18: FURB101 [*] `open` and `read` should be replaced by `Path(self.context.filename).read_text(encoding="utf-8")`
- scripts/codemods/base.py:51:18: FURB101 `open` and `read` should be replaced by `Path(self.context.filename).read_text(encoding="utf-8")`
+ setup.py:8:6: FURB101 [*] `open` and `read` should be replaced by `Path("disnake/__init__.py").read_text(encoding="utf-8")`
- setup.py:8:6: FURB101 `open` and `read` should be replaced by `Path("disnake/__init__.py").read_text(encoding="utf-8")`
... 1 additional changes omitted for rule FURB101

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

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

+ airflow-core/src/airflow/cli/commands/pool_command.py:117:10: FURB101 [*] `open` and `read` should be replaced by `Path(filepath).read_text()`
- airflow-core/src/airflow/cli/commands/pool_command.py:117:10: FURB101 `open` and `read` should be replaced by `Path(filepath).read_text()`
+ airflow-core/src/airflow/cli/commands/pool_command.py:147:10: FURB103 [*] `open` and `write` should be replaced by `Path(filepath)....`
- airflow-core/src/airflow/cli/commands/pool_command.py:147:10: FURB103 `open` and `write` should be replaced by `Path(filepath)....`
+ airflow-core/src/airflow/example_dags/example_kubernetes_executor.py:90:18: FURB103 [*] `open` and `write` should be replaced by `Path("/foo/volume_mount_test.txt").write_text("Hello")`
- airflow-core/src/airflow/example_dags/example_kubernetes_executor.py:90:18: FURB103 `open` and `write` should be replaced by `Path("/foo/volume_mount_test.txt").write_text("Hello")`
+ airflow-core/src/airflow/secrets/local_filesystem.py:119:10: FURB101 [*] `open` and `read` should be replaced by `Path(file_path).read_text()`
- airflow-core/src/airflow/secrets/local_filesystem.py:119:10: FURB101 `open` and `read` should be replaced by `Path(file_path).read_text()`
+ airflow-core/src/airflow/secrets/local_filesystem.py:142:10: FURB101 [*] `open` and `read` should be replaced by `Path(file_path).read_text()`
- airflow-core/src/airflow/secrets/local_filesystem.py:142:10: FURB101 `open` and `read` should be replaced by `Path(file_path).read_text()`
+ airflow-core/src/airflow/secrets/local_filesystem.py:68:10: FURB101 [*] `open` and `read` should be replaced by `Path(file_path).read_text()`
... 72 additional changes omitted for rule FURB101
+ airflow-core/tests/integration/otel/dags/otel_test_dag_with_pause_between_tasks.py:118:10: FURB103 [*] `open` and `write` should be replaced by `Path(control_file).write_text("pause")`
... 196 additional changes omitted for project

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

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

+ superset/cli/importexport.py:155:14: FURB101 [*] `open` and `read` should be replaced by `Path(path).read_text()`
- superset/cli/importexport.py:155:14: FURB101 `open` and `read` should be replaced by `Path(path).read_text()`
+ superset/cli/importexport.py:192:18: FURB101 [*] `open` and `read` should be replaced by `Path(path).read_text()`
- superset/cli/importexport.py:192:18: FURB101 `open` and `read` should be replaced by `Path(path).read_text()`
+ superset/cli/importexport.py:231:14: FURB103 [*] `open` and `write` should be replaced by `Path(dashboard_file).write_text(data)`
- superset/cli/importexport.py:231:14: FURB103 `open` and `write` should be replaced by `Path(dashboard_file).write_text(data)`
+ superset/cli/importexport.py:325:14: FURB101 [*] `open` and `read` should be replaced by `Path(path_).read_text()`
- superset/cli/importexport.py:325:14: FURB101 `open` and `read` should be replaced by `Path(path_).read_text()`
... 11 additional changes omitted for rule FURB101
+ superset/utils/core.py:1482:14: FURB103 [*] `open` and `write` should be replaced by `Path(path).write_text(certificate)`
- superset/utils/core.py:1482:14: FURB103 `open` and `write` should be replaced by `Path(path).write_text(certificate)`
... 18 additional changes omitted for project

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

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

+ examples/models/basic_plot.py:42:10: FURB103 [*] `open` and `write` should be replaced by `Path(filename)....`
- examples/models/basic_plot.py:42:10: FURB103 `open` and `write` should be replaced by `Path(filename)....`
+ examples/models/buttons.py:75:10: FURB103 [*] `open` and `write` should be replaced by `Path(filename).write_text(file_html(title="Button widgets", doc))`
- examples/models/buttons.py:75:10: FURB103 `open` and `write` should be replaced by `Path(filename).write_text(file_html(title="Button widgets", doc))`
+ examples/models/calendars.py:104:10: FURB103 [*] `open` and `write` should be replaced by `Path(filename).write_text(file_html(title="Calendar 2014", doc))`
- examples/models/calendars.py:104:10: FURB103 `open` and `write` should be replaced by `Path(filename).write_text(file_html(title="Calendar 2014", doc))`
... 73 additional changes omitted for rule FURB103
+ examples/server/app/movies/main.py:28:6: FURB101 [*] `open` and `read` should be replaced by `Path(join(dirname(__file__), "razzies-clean.csv")).read_text()`
- examples/server/app/movies/main.py:28:6: FURB101 `open` and `read` should be replaced by `Path(join(dirname(__file__), "razzies-clean.csv")).read_text()`
+ scripts/milestone.py:315:10: FURB101 [*] `open` and `read` should be replaced by `Path(CHANGELOG).read_text()`
- scripts/milestone.py:315:10: FURB101 `open` and `read` should be replaced by `Path(CHANGELOG).read_text()`
... 100 additional changes omitted for project

ibis-project/ibis (+0 -0 violations, +8 -0 fixes)

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

+ .github/workflows/algolia/upload-algolia-api.py:165:14: FURB101 [*] `open` and `read` should be replaced by `Path(qmd).read_text()`
- .github/workflows/algolia/upload-algolia-api.py:165:14: FURB101 `open` and `read` should be replaced by `Path(qmd).read_text()`
+ docs/posts/pydata-performance-part2/datafusion_native.py:5:6: FURB101 [*] `open` and `read` should be replaced by `Path("./datafusion_native.sql").read_text()`
- docs/posts/pydata-performance-part2/datafusion_native.py:5:6: FURB101 `open` and `read` should be replaced by `Path("./datafusion_native.sql").read_text()`
+ ibis/backends/duckdb/tests/test_decompile_tpch.py:78:10: FURB101 [*] `open` and `read` should be replaced by `Path(tpch_query_file).read_text()`
- ibis/backends/duckdb/tests/test_decompile_tpch.py:78:10: FURB101 `open` and `read` should be replaced by `Path(tpch_query_file).read_text()`
... 1 additional changes omitted for rule FURB101
+ ibis/expr/visualize.py:182:14: FURB103 [*] `open` and `write` should be replaced by `Path(path).write_bytes(piped_source)`
- ibis/expr/visualize.py:182:14: FURB103 `open` and `write` should be replaced by `Path(path).write_bytes(piped_source)`

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

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

+ src/latch/executions.py:56:14: FURB101 [*] `open` and `read` should be replaced by `Path("/etc/hostname").read_text()`
- src/latch/executions.py:56:14: FURB101 `open` and `read` should be replaced by `Path("/etc/hostname").read_text()`
+ src/latch_cli/services/get_executions.py:366:14: FURB103 [*] `open` and `write` should be replaced by `Path(log_file)....`
- src/latch_cli/services/get_executions.py:366:14: FURB103 `open` and `write` should be replaced by `Path(log_file)....`
+ src/latch_cli/services/init/init.py:42:10: FURB103 [*] `open` and `write` should be replaced by `Path(version_f).write_text("0.0.0")`
- src/latch_cli/services/init/init.py:42:10: FURB103 `open` and `write` should be replaced by `Path(version_f).write_text("0.0.0")`
+ src/latch_cli/utils/__init__.py:336:10: FURB103 [*] `open` and `write` should be replaced by `Path(cache_location)....`
- src/latch_cli/utils/__init__.py:336:10: FURB103 `open` and `write` should be replaced by `Path(cache_location)....`
... 7 additional changes omitted for rule FURB103
+ src/latch_cli/utils/__init__.py:345:14: FURB101 [*] `open` and `read` should be replaced by `Path(cache_location).read_text()`
- src/latch_cli/utils/__init__.py:345:14: FURB101 `open` and `read` should be replaced by `Path(cache_location).read_text()`
... 6 additional changes omitted for project

pypa/setuptools (+0 -0 violations, +64 -0 fixes)

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

+ pkg_resources/__init__.py:2128:14: FURB101 [*] `open` and `read` should be replaced by `Path(file_path).read_bytes()`
- pkg_resources/__init__.py:2128:14: FURB101 `open` and `read` should be replaced by `Path(file_path).read_bytes()`
+ pkg_resources/__init__.py:2203:14: FURB101 [*] `open` and `read` should be replaced by `Path(self.path).read_text(encoding='utf-8', errors="replace")`
- pkg_resources/__init__.py:2203:14: FURB101 `open` and `read` should be replaced by `Path(self.path).read_text(encoding='utf-8', errors="replace")`
+ pkg_resources/tests/test_pkg_resources.py:188:10: FURB103 [*] `open` and `write` should be replaced by `Path(metadata_path).write_bytes(metadata)`
- pkg_resources/tests/test_pkg_resources.py:188:10: FURB103 `open` and `write` should be replaced by `Path(metadata_path).write_bytes(metadata)`
+ setuptools/archive_util.py:133:18: FURB103 [*] `open` and `write` should be replaced by `Path(target).write_bytes(data)`
- setuptools/archive_util.py:133:18: FURB103 `open` and `write` should be replaced by `Path(target).write_bytes(data)`
+ setuptools/command/bdist_egg.py:70:10: FURB103 [*] `open` and `write` should be replaced by `Path(pyfile)....`
- setuptools/command/bdist_egg.py:70:10: FURB103 `open` and `write` should be replaced by `Path(pyfile)....`
... 21 additional changes omitted for rule FURB103
... 54 additional changes omitted for project

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

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

+ corporate/tests/test_stripe.py:187:14: FURB101 [*] `open` and `read` should be replaced by `Path(fixture_path).read_bytes()`
- corporate/tests/test_stripe.py:187:14: FURB101 `open` and `read` should be replaced by `Path(fixture_path).read_bytes()`
+ corporate/tests/test_stripe.py:280:14: FURB101 [*] `open` and `read` should be replaced by `Path(fixture_file).read_text()`
- corporate/tests/test_stripe.py:280:14: FURB101 `open` and `read` should be replaced by `Path(fixture_file).read_text()`
+ corporate/tests/test_stripe.py:306:14: FURB103 [*] `open` and `write` should be replaced by `Path(fixture_file).write_text(file_content)`
- corporate/tests/test_stripe.py:306:14: FURB103 `open` and `write` should be replaced by `Path(fixture_file).write_text(file_content)`
+ corporate/views/portico.py:286:14: FURB101 [*] `open` and `read` should be replaced by `Path(settings.CONTRIBUTOR_DATA_FILE_PATH).read_bytes()`
- corporate/views/portico.py:286:14: FURB101 `open` and `read` should be replaced by `Path(settings.CONTRIBUTOR_DATA_FILE_PATH).read_bytes()`
+ scripts/lib/puppet_cache.py:23:10: FURB101 [*] `open` and `read` should be replaced by `Path(PUPPET_DEPS_FILE_PATH).read_text()`
- scripts/lib/puppet_cache.py:23:10: FURB101 `open` and `read` should be replaced by `Path(PUPPET_DEPS_FILE_PATH).read_text()`
... 157 additional changes omitted for rule FURB101
+ scripts/lib/zulip_tools.py:538:10: FURB103 [*] `open` and `write` should be replaced by `Path(hash_path).write_text(new_hash)`
- scripts/lib/zulip_tools.py:538:10: FURB103 `open` and `write` should be replaced by `Path(hash_path).write_text(new_hash)`
+ scripts/lib/zulip_tools.py:728:10: FURB103 [*] `open` and `write` should be replaced by `Path(path + ".tmp")....`
- scripts/lib/zulip_tools.py:728:10: FURB103 `open` and `write` should be replaced by `Path(path + ".tmp")....`
... 226 additional changes omitted for project

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
FURB103 442 0 0 442 0
FURB101 398 0 0 398 0

@chirizxc
Copy link
Contributor Author

@ntBre I think this PR can include furb103 as well, in essence the code will be almost identical

@chirizxc chirizxc changed the title [refurb] Add fix forread-whole-file (FURB101) [refurb] Add fixes for FURB101, FURB103 Sep 23, 2025
@ntBre ntBre added fixes Related to suggested fixes for violations preview Related to preview mode features labels Sep 25, 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.

Thank you! This looks great overall, I just had a few nits and a couple of slightly larger suggestions.

# Conflicts:
#	crates/ruff_linter/src/preview.rs
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 just had one clarification about earlier suggestion, but this looks good to me otherwise.

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! I went through a few of the ecosystem results, and they all look right to me too.

@ntBre ntBre merged commit b66a3e7 into astral-sh:main Oct 6, 2025
36 checks passed
@chirizxc chirizxc deleted the furb101-fix branch October 6, 2025 22:51
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