{"id":24798,"library":"urlpath","title":"urlpath","description":"Object-oriented URL classes built on urllib.parse and pathlib for Python 3.9+. Version 2.0.0 switches license from PSF to MIT, drops support for Python 3.4-3.8, and restructures from a single-file module to a multi-module package. Generally stable with infrequent releases.","status":"active","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/brandonschabell/urlpath","tags":["URL","pathlib","urllib","object-oriented"],"install":[{"cmd":"pip install urlpath","lang":"bash","label":"Install urlpath"}],"dependencies":[],"imports":[{"note":"Common mistake: using old single-file import style before v2.0.0 restructured the package.","wrong":"import urlpath\nurlpath.URL('/path')","symbol":"URL","correct":"from urlpath import URL"}],"quickstart":{"code":"from urlpath import URL\n\nurl = URL('https://api.example.com/resource/123')\nprint(url.scheme)    # 'https'\nprint(url.host)      # 'api.example.com'\nprint(url.path)      # '/resource/123'\nprint(url.parent())  # URL('https://api.example.com/resource')\nprint(url.name)      # '123'\n\n# Chaining\nnew_url = url / 'sub' / 'item'\nprint(new_url)       # 'https://api.example.com/resource/123/sub/item'\n\n# Query params\nquery_url = URL('https://example.com/search').with_query({'q': 'test', 'page': '1'})\nprint(query_url)     # 'https://example.com/search?q=test&page=1'\n\n# Check if URL is absolute\nprint(url.is_absolute())  # True","lang":"python","description":"Basic usage of URL class with path joining and query parameters."},"warnings":[{"fix":"Update imports to use the public API from 'urlpath' (e.g., 'from urlpath import URL').","message":"In v2.0.0 the package changed from a single-file module to a multi-module package. Any code relying on internal module paths (e.g., importing directly from 'urlpath.py' or accessing private attributes) may break.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade Python to 3.9 or later.","message":"Python 3.8 and earlier are no longer supported. The package requires Python 3.9+.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Convert URL to string with str(url) or use .url attribute to get the full string representation.","message":"URL path operations (like '/' for joining) return a new URL object, not a string. Forgetting to call str() or print() can lead to confusing output.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from urlpath import URL' instead of 'import urlpath' then 'urlpath.URL'.","cause":"Importing the module instead of the class from it (old style before v2.0.0).","error":"AttributeError: module 'urlpath' has no attribute 'URL'"},{"fix":"Create a URL object first: url = URL('https://example.com') then call url.parent().","cause":"Treating a string as a URL object. Path operations return a URL, not a string.","error":"AttributeError: 'str' object has no attribute 'parent'"},{"fix":"Convert URL to string via str(url) or url.url before passing to non-urlpath functions.","cause":"Using a URL object where a string is expected (e.g., as argument to os.path functions).","error":"TypeError: expected str, bytes or os.PathLike object, not URL"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}