-
Notifications
You must be signed in to change notification settings - Fork 151
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
Define SettingCodes and improve ChangedSetting representation. #469
Conversation
66c0e9d
to
6843036
Compare
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.
This is generally pretty good! I have a few small notes.
h2/settings.py
Outdated
""" | ||
All known HTTP/2 setting codes. | ||
|
||
.. versionadded:: 2.5.3 |
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.
This docstring can be dedented.
As to the versionadded comment, this won't be able to make it into the 2.5 release because this is a public part of the API, and so will need to go into 2.6. So the version added is 2.6.0.
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.
Done.
h2/settings.py
Outdated
HEADER_TABLE_SIZE = SettingsFrame.HEADER_TABLE_SIZE | ||
#: | ||
#: .. deprecated:: 2.6.0 | ||
#: Deprecated in favour of :class:`SettingCodes.HEADER_TABLE_SIZE |
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.
These are all class
but should be data
, I think.
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.
Done.
MAX_FRAME_SIZE = SettingsFrame.MAX_FRAME_SIZE | ||
def __init__(self, setting, original_value, new_value): | ||
#: The setting code given. Either one of :class:`SettingCodes | ||
#: <h2.settings.SettingCodes>` or ``int`` |
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.
This should get a .. versionchanged:: 2.6.0
note as well.
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.
Done.
h2/settings.py
Outdated
def __repr__(self): | ||
return ("ChangedSetting(setting=%s, original_value=%s, " | ||
"new_value=%s)") % ( | ||
self.setting.name, |
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.
Does .name
work here in all cases?
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 should... Do you want me to add an if isinstance(self.setting, SettingCodes)
check?
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.
Well, I mean: it definitely won't work for integers, right? 😁
Rather than isinstance, are you happy to just tolerate the default repr of an intenum member?
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.
How about we make sure that the init of ChangedSetting
always converts it to and SettingCodes
object?
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't convert to an enum if you don't have a member defined for that int.
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.
Ok, I'll changed it to use the default repr.
6843036
to
cd6e892
Compare
h2/settings.py
Outdated
""" | ||
All known HTTP/2 setting codes. | ||
|
||
.. versionadded:: 2.5.3 |
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.
2.6.0, surely?
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.
Done.
59be0d2
to
d115923
Compare
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.
Ok, one small note about list creation and then we're good to go I think.
h2/events.py
Outdated
return "<RemoteSettingsChanged changed_settings:%s>" % ( | ||
self.changed_settings, | ||
return "<RemoteSettingsChanged changed_settings:{%s}>" % ( | ||
", ".join([repr(cs) for cs in self.changed_settings.values()]), |
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.
Small note here, but you don't need the list. join
works just fine on generators, so we can save ourselves the allocation of an intermediate list here and below.
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.
Done.
self.setting, | ||
self.original_value, | ||
self.new_value | ||
) |
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.
Wow. This looks weird. It fits in with the code style, so...I guess we'll leave it.
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.
Either this, or you allow lines with more than 79 characters! 😄
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.
NEVER!
d115923
to
8620dba
Compare
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.
Cool, LGTM. Thanks for this @Kriechi! 🚀
self.setting, | ||
self.original_value, | ||
self.new_value | ||
) |
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.
NEVER!
fixes #359
based on #303