Skip to content

urlpathyarl as URL manipulation library

Context

We use URL class from urlpath library a lot. It automates URL manipulations.

grep --include '*.py' -R URL yaml_ld | head
yaml_ld/string_as_url_or_path.py:from urlpath import URL
yaml_ld/string_as_url_or_path.py:def as_url_or_path(raw: str) -> URL | Path:
yaml_ld/string_as_url_or_path.py:    """Interpret a raw string as a URL or a local disk path."""
yaml_ld/string_as_url_or_path.py:    if (url := URL(raw)).scheme:
yaml_ld/models.py:from urlpath import URL
yaml_ld/models.py:    JsonLdRecord | Sequence[JsonLdRecord] | str | Path | URL | RemoteDocument
yaml_ld/models.py:    expand_context: JsonLdRecord | str | Path | URL | None = None
yaml_ld/document_loaders/choice_by_scheme.py:from urlpath import URL
yaml_ld/document_loaders/choice_by_scheme.py:    Cannot choose the loader by URL protocol.
yaml_ld/document_loaders/choice_by_scheme.py:    * URL: `{self.url}`

But, last PyPI release of urlpath has been published on 2021-11-12, which is also the date of the last commit at the project GitHub repository. That is the reason why urlpath is incompatible with Python 3.12.

Alternatives

Library Stars Last Release
yarl 1.3k 2023-12-06
furl 2.6k 2021-09-28

Decision

Use yarl as a library that's current and regularly updated.