-
-
Notifications
You must be signed in to change notification settings - Fork 359
Add User-Agent header with Hatch, Python and HTTPX versions #1827
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
Conversation
cjames23
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for providing this! Can you adjust tests to confirm headers as a test to avoid regressions in the future?
|
Yes, added, how's this? |
ofek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
|
||
| user_agent = ( | ||
| f"Hatch/{__version__} " | ||
| f"{platform.python_implementation()}/{platform.python_version()} " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, can we achieve the same with sys or somehow not use platform? This is purely theoretical as it wouldn't matter when we're doing something heavy already like making network requests.
❯ python -m timeit -n 1 -r 1 "import platform"
1 loop, best of 1: 5.52 msec per loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be done with sys.implementation.name and sys.implementation.version
Fixes #1816.
Add a User-Agent header such as:
Hatch/1.12.1.dev42 CPython/3.12.7 HTTPX/0.27.2