Skip to content

[flake8-use-pathlib] Avoid bytes-path false positives in PTH rules#24701

Open
BerqiaMouad wants to merge 7 commits intoastral-sh:mainfrom
BerqiaMouad:mouad/pth-bytes-paths
Open

[flake8-use-pathlib] Avoid bytes-path false positives in PTH rules#24701
BerqiaMouad wants to merge 7 commits intoastral-sh:mainfrom
BerqiaMouad:mouad/pth-bytes-paths

Conversation

@BerqiaMouad
Copy link
Copy Markdown

Summary

  • suppress flake8-use-pathlib diagnostics when the relevant operand is bytes-backed
  • apply the bytes-path guard in both the shared replacement helpers and the custom rule handlers that bypass them
  • add a dedicated bytes_paths.py fixture and refresh the affected snapshots

This addresses #17699.

Testing

cargo test -p ruff_linter flake8_use_pathlib
cargo fmt --check
cargo clippy -p ruff_linter --all-targets -- -D warnings
target/debug/ruff check --isolated --select PTH208 - <<'PY'
import os
os.listdir(b'.')
PY
target/debug/ruff check --isolated --select PTH208 - <<'PY'
import os
os.listdir('.')
PY
target/debug/ruff check --isolated --select PTH123 - <<'PY'
open(b'foo')
PY
target/debug/ruff check --isolated --select PTH121 - <<'PY'
import os
os.path.samefile(b'a', 'a')
PY

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@astral-sh-bot astral-sh-bot Bot requested a review from ntBre April 17, 2026 20:43
@ntBre
Copy link
Copy Markdown
Contributor

ntBre commented Apr 20, 2026

Thanks for looking into this. Could you confirm that you've read and followed our AI policy before I review this?

@BerqiaMouad
Copy link
Copy Markdown
Author

Thanks for looking into this. Could you confirm that you've read and followed our AI policy before I review this?

thank you for response, yes i read and followed it !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants