Skip to content

Enable ruff PTH rule (migrate to pathlib)#2004

Merged
iMicknl merged 1 commit intov2/mainfrom
v2/ruff-pth
Apr 19, 2026
Merged

Enable ruff PTH rule (migrate to pathlib)#2004
iMicknl merged 1 commit intov2/mainfrom
v2/ruff-pth

Conversation

@iMicknl
Copy link
Copy Markdown
Owner

@iMicknl iMicknl commented Apr 19, 2026

Summary

  • Replace os.path usage with pathlib.Path in test_client.py and mask_fixtures.py
  • Remove os import where no longer needed

Test plan

  • ruff check . passes
  • pytest — 280 tests pass

Copilot AI review requested due to automatic review settings April 19, 2026 17:21
@iMicknl iMicknl requested a review from tetienne as a code owner April 19, 2026 17:21
@iMicknl iMicknl added enhancement New feature or request v2 labels Apr 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables Ruff’s flake8-pathlib (PTH) ruleset and updates a couple of places to use pathlib.Path instead of os.path, aligning the codebase with the new linting expectations.

Changes:

  • Enable Ruff PTH rules in pyproject.toml.
  • Migrate path handling to pathlib.Path in tests/test_client.py and utils/mask_fixtures.py.
  • Remove now-unneeded os/glob imports where applicable.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
utils/mask_fixtures.py Replace glob/os.path.join + open() with Path.glob() + Path.open().
tests/test_client.py Replace os.path path construction with Path composition for fixture reads.
pyproject.toml Turn on Ruff PTH lint ruleset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_client.py Outdated
Comment thread tests/test_client.py Outdated
# ruff: noqa: ASYNC230, S106
# ruff: noqa: S106
# S106: Test credentials use dummy values.
# ASYNC230: Blocking open() is acceptable for reading test fixtures
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file header comment mentions ASYNC230, but the file-level # ruff: noqa no longer ignores ASYNC230. Either remove/update the ASYNC230 comment or add ASYNC230 back to the noqa list so the header accurately reflects the lint configuration for this file.

Suggested change
# ASYNC230: Blocking open() is acceptable for reading test fixtures

Copilot uses AI. Check for mistakes.
Comment thread tests/test_client.py Outdated
Comment thread tests/test_client.py Outdated
Comment on lines 326 to 327
with (CURRENT_DIR / "fixtures/setup/setup_tahoma_1.json").open(
encoding="utf-8",
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like above, this builds the path using a string containing separators ("fixtures/setup/setup_tahoma_1.json"). Prefer composing the path with separate segments (e.g., "fixtures" / "setup" / "setup_tahoma_1.json") to keep pathlib usage consistent and platform-agnostic.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_client.py Outdated
- Replace os.path with pathlib.Path in tests and utils
- Use Path / operator with split segments for consistency
- Remove stale ASYNC230 noqa comment
@iMicknl iMicknl merged commit a35befd into v2/main Apr 19, 2026
8 checks passed
@iMicknl iMicknl deleted the v2/ruff-pth branch April 19, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants