Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User-Agent header with Hatch, Python and HTTPX versions #1827

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/hatch/index/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import hyperlink

from hatch._version import __version__

if TYPE_CHECKING:
import httpx

Expand Down Expand Up @@ -47,11 +49,19 @@ def __init__(self, repo: str, *, user='', auth='', ca_cert=None, client_cert=Non

@cached_property
def client(self) -> httpx.Client:
import platform

import httpx

from hatch.utils.network import DEFAULT_TIMEOUT

user_agent = (
f'Hatch/{__version__} '
f'{platform.python_implementation()}/{platform.python_version()} '
f'HTTPX/{httpx.__version__}'
)
return httpx.Client(
headers={'User-Agent': user_agent},
transport=httpx.HTTPTransport(retries=3, verify=self.__verify, cert=self.__cert),
timeout=DEFAULT_TIMEOUT,
)
Expand Down