Skip to content

Conversation

@brandonschabell
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings October 13, 2025 16:00
Copy link

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

This PR refactors Python version compatibility checks and reduces code duplication by introducing centralized utilities. The main focus is on cleaning up repeated version checks throughout the codebase and consolidating common functionality.

  • Centralized Python 3.12+ version check in a dedicated compatibility module
  • Added reusable cleanup_escapes function to eliminate duplicate escape sequence handling
  • Removed numerous inline version checks in favor of the centralized constant

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
urlpath/_compat.py New compatibility module with centralized Python version check
urlpath/_utils.py Added cleanup_escapes function and updated all exports
urlpath/_url.py Replaced sys.version_info checks with IS_PY312_PLUS constant
urlpath/_flavour.py Updated version check and improved type checking compatibility

Comment on lines +14 to +16
if not TYPE_CHECKING and not IS_PY312_PLUS:
from pathlib import _PosixFlavour
else:
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The conditional import logic is complex and could be simplified. Consider using a try/except ImportError pattern which would be more readable and handle the import availability directly.

Suggested change
if not TYPE_CHECKING and not IS_PY312_PLUS:
from pathlib import _PosixFlavour
else:
try:
from pathlib import _PosixFlavour
except ImportError:

Copilot uses AI. Check for mistakes.
Comment on lines +1354 to +1355
result = super().joinpath(*pathsegments)
return result # type: ignore[return-value]
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

The intermediate variable assignment is unnecessary. The code can be simplified to 'return super().joinpath(*pathsegments) # type: ignore[return-value]'.

Suggested change
result = super().joinpath(*pathsegments)
return result # type: ignore[return-value]
return super().joinpath(*pathsegments) # type: ignore[return-value]

Copilot uses AI. Check for mistakes.
@brandonschabell brandonschabell merged commit 3ea847d into main Oct 13, 2025
7 checks passed
@brandonschabell brandonschabell deleted the cleanup branch October 13, 2025 16:02
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