action0-url

Easy URL parsing, manipulation and unparsing — a friendly, typed wrapper around urllib.parse.

pip install action0-url    # or: uv add action0-url
from action0.url import Url

url = Url("https://www.example.com/path/filename.json?foo=bar")
url.query.set("foo", "baz")
url.hostname = "api.example.com"
print(url)
# https://api.example.com/path/filename.json?foo=baz

Highlights

  • Every URL part (scheme, hostname, port, path, fragment, …) is a plain mutable attribute — parse once, change what you need, render again.

  • Query and path parameters are dict-like, multi-value aware Params mappings.

  • Convenience methods for everyday work: join(), the / operator, copy(), origin(), normalize(), pathlib-style parent / name / suffix.

  • Parts are stored percent-decoded and re-encoded on rendering; non-ASCII hostnames become punycode.

  • Fully typed (checked with mypy strict, pyright and ty), zero runtime dependencies, Python 3.11+.

The action0 namespace is simply the one the author likes to use for personal projects.