{"id":27832,"library":"ghrepo","title":"ghrepo","description":"A Python library for parsing and constructing GitHub repository URLs and specifiers (e.g., 'owner/repo'). Current version 0.7.1, requires Python >=3.8. Released on PyPI with moderate cadence.","status":"active","version":"0.7.1","language":"python","source_language":"en","source_url":"https://github.com/nicklausw/ghrepo","tags":["github","url-parsing","repository","git"],"install":[{"cmd":"pip install ghrepo","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"GHRepo","correct":"from ghrepo import GHRepo"},{"note":"","wrong":"","symbol":"parse","correct":"from ghrepo import parse"}],"quickstart":{"code":"from ghrepo import GHRepo, parse\n\n# Parse a URL\nrepo = GHRepo('https://github.com/owner/repo')\nprint(repo.owner, repo.name)  # owner repo\n\n# Construct from specifier\nrepo2 = GHRepo('owner/repo')\nprint(repo2.url)  # https://github.com/owner/repo\n\n# Parse using function\nrepo3 = parse('owner/repo')\nprint(repo3.full_name)  # owner/repo\n\n# Auth (example with token)\nimport os\ntoken = os.environ.get('GITHUB_TOKEN', '')\nif token:\n    repo4 = GHRepo('owner/repo', token=token)\n    print(repo4.clone_url)  # https://x-access-token:...@github.com/owner/repo.git","lang":"python","description":"Basic usage: create GHRepo from URL or specifier, get components and URLs."},"warnings":[{"fix":"Use GHRepo(url) instead of GHRepo.from_url(url).","message":"The 'from_url' class method is deprecated in favor of GHRepo() constructor directly.","severity":"deprecated","affected_versions":">=0.7.0"},{"fix":"Strip trailing slashes before passing to GHRepo or parse().","message":"Strings with trailing slash cause ValueError. URLs must not end with a slash.","severity":"gotcha","affected_versions":"all"},{"fix":"Use a dedicated library like github3.py for enterprise support, or manually handle.","message":"GitHub Enterprise URLs are not supported. Only github.com (or github.com subdomains?) tested.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Strip trailing slash: GHRepo('owner/repo'.rstrip('/'))","cause":"Input string has trailing slash, which is invalid for this library.","error":"ValueError: Could not parse 'owner/repo/' as a GitHub repo"},{"fix":"Ensure proper usage: repo = GHRepo('url') then use repo.owner, not reassign repo to string.","cause":"User called GHRepo as a function returning string? Actually GHRepo is a class, but if someone writes repo = GHRepo('url') and then repo = 'something', they get this.","error":"AttributeError: 'str' object has no attribute 'owner'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}