Skip to content

Conversation

@brandonschabell
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings October 13, 2025 15:09
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 restructures the URLPath module from a monolithic single-file design to a more maintainable multi-module architecture. The main purpose is to improve code organization and maintainability by separating concerns into dedicated modules.

Key changes:

  • Split the large urlpath/__init__.py into separate modules for utilities, URL classes, and pathlib flavour logic
  • Simplified the main __init__.py to serve as a clean public API entry point
  • Updated the Makefile to consolidate formatting and linting commands

Reviewed Changes

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

Show a summary per file
File Description
urlpath/__init__.py Converted to a clean public API module that imports from submodules
urlpath/_utils.py New module containing utility classes (FrozenDict, cached_property, etc.)
urlpath/_url.py New module containing the main URL and JailedURL class implementations
urlpath/_flavour.py New module containing the custom pathlib flavour for URL parsing
Makefile Consolidated format and lint commands into simpler fix and check targets


from __future__ import annotations

__all__ = ("FrozenDict", "FrozenMultiDict", "MultiDictMixin", "cached_property", "netlocjoin", "_url_splitroot")
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 all tuple includes internal functions like _url_splitroot which are prefixed with underscore to indicate they're private. Consider removing private functions from all or making them properly public if they need to be exported.

Suggested change
__all__ = ("FrozenDict", "FrozenMultiDict", "MultiDictMixin", "cached_property", "netlocjoin", "_url_splitroot")
__all__ = ("FrozenDict", "FrozenMultiDict", "MultiDictMixin", "cached_property", "netlocjoin")

Copilot uses AI. Check for mistakes.
Comment on lines +81 to +82
combined = cls._combine_args(canonicalized_args)
return super().__new__(cls, *combined)
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 condition len(canonicalized_args) > 1 is used in multiple places with identical logic. Consider extracting this into a helper method to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +103
if len(canonicalized_args) > 1:
combined = type(self)._combine_args(canonicalized_args) # type: ignore[attr-defined]
super().__init__(*combined)
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.

This duplicates the same multi-argument combination logic from new. The duplication could lead to inconsistencies if the logic needs to change. Consider extracting this pattern into a shared helper method.

Copilot uses AI. Check for mistakes.
has_drv = True # drive is scheme + netloc
is_supported = True # supported in all platform

def splitroot(self, part: str, sep: str = _PosixFlavour.sep) -> tuple[str, str, str]:
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.

Using _PosixFlavour.sep directly in the default parameter creates a tight coupling and could cause issues if _PosixFlavour is None (as it is in Python 3.12+). Consider using a string literal / instead for consistency with the Python 3.12+ version.

Suggested change
def splitroot(self, part: str, sep: str = _PosixFlavour.sep) -> tuple[str, str, str]:
def splitroot(self, part: str, sep: str = "/") -> tuple[str, str, str]:

Copilot uses AI. Check for mistakes.
@brandonschabell brandonschabell merged commit 67a66f8 into main Oct 13, 2025
7 checks passed
@brandonschabell brandonschabell deleted the restructure-repo branch October 13, 2025 15:12
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