-
-
Notifications
You must be signed in to change notification settings - Fork 1k
added test for HTTPVersionConfig type error #253
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
lovelydinosaur
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.
Good call, yup!
One minor point for consideration.
httpx/config.py
Outdated
| } | ||
| else: | ||
| self.http_versions = {version.upper() for version in http_versions} | ||
| raise ValueError(f"Unsupported HTTP version {http_versions!r}.") |
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.
I guess we should probably raise a type error instead. Something like...
TypeError("HTTP version should be a string or list of strings, but got {type(http_versions)}")?
37f7915 to
1e5055a
Compare
httpx/config.py
Outdated
| @@ -1,5 +1,6 @@ | |||
| import ssl | |||
| import typing | |||
| from collections.abc import Iterable | |||
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.
Why collections.abc.Iterable instead of typing.Iterable?
https://docs.python.org/3/library/typing.html#typing.Iterable
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.
I didn't think to use types like this :) thanks
httpx/config.py
Outdated
| else: | ||
| self.http_versions = {version.upper() for version in http_versions} | ||
| raise TypeError( | ||
| f"HTTP version should be a string or list of strings, but got {type(http_versions)}" |
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.
You can break this into two strings to appease flake8:
| f"HTTP version should be a string or list of strings, but got {type(http_versions)}" | |
| "HTTP version should be a string or list of strings," | |
| f" but got {type(http_versions)}" |
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, I overlooked flake8 error. if flake8 is not successful, nox can be stopped.
1e5055a to
52308f4
Compare
sethmlarson
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.
Looks good, thanks @cansarigol!
Related #241