-
Notifications
You must be signed in to change notification settings - Fork 197
Accept language wip #335
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
Merged
digitalresistor
merged 99 commits into
Pylons:master
from
whiteroses:accept-language-wip
Aug 28, 2017
Merged
Accept language wip #335
Changes from all commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
b62746a
Add AcceptLanguageValidHeader class with .__init__ and .parse().
whiteroses 085d847
Document instance attributes of AcceptLanguageValidHeader.
whiteroses 0298dfc
Add AcceptLanguageValidHeader.basic_filtering().
whiteroses f3faed0
Fix comment.
whiteroses 3acd533
Improve docstring.
whiteroses a35a98b
Make comment more precise.
whiteroses 1e17ac3
Replace loop with any() and a generator.
whiteroses c402919
Add AcceptLanguageValidHeader.lookup().
whiteroses 2d7619d
Add AcceptLanguage._old_match.
whiteroses 7d50f17
Add AcceptLanguageValidHeader.__iter__.
whiteroses ba91ba7
Add AcceptLanguageValidHeader.__contains__.
whiteroses aae932f
Improve comment.
whiteroses 8d6a4a9
Fix typo.
whiteroses 0c6df1a
Add AcceptLanguageValidHeader.best_match.
whiteroses d18f69a
Minor rewording in docstring.
whiteroses 3afb478
Add AcceptLanguageValidHeader.quality().
whiteroses aa94a27
Add colon.
whiteroses cc422c7
Make heading bold.
whiteroses 59b8b75
Improve docstring.
whiteroses e9679b9
Add deprecation warnings.
whiteroses 218b1d1
Add _AcceptLanguageInvalidOrNoHeader class.
whiteroses 5c849e8
Add _AcceptLanguageInvalidOrNoHeader.__contains__ and test.
whiteroses decbb08
Fix docstring.
whiteroses 71b8f95
Add _AcceptLanguageInvalidOrNoHeader.__iter__.
whiteroses d33edf3
Add _AcceptLanguageInvalidOrNoHeader.__nonzero__.
whiteroses 5c4762b
Add AcceptLanguageValidHeader.__nonzero__/.__bool__ and test.
whiteroses db2b411
Add _AcceptLanguageInvalidOrNoHeader.basic_filtering.
whiteroses 5e9a364
Add missing space.
whiteroses 660aef9
Add _AcceptLanguageInvalidOrNoHeader.best_match.
whiteroses 2e35a87
Remove call to _check_offer().
whiteroses 7cdf90e
Add _AcceptLanguageInvalidOrNoHeader.quality.
whiteroses df056c4
Add _AcceptLanguageInvalidOrNoHeader.lookup and tests.
whiteroses 0145b79
Add AcceptLanguageNoHeader class, __init__, test and documentation.
whiteroses 8f459bf
Add AcceptLanguageInvalidHeader class, __init__, test and doc.
whiteroses 10a89f2
Add __repr__ and tests for the three AcceptLanguage classes.
whiteroses 009374d
Add __str__ and tests for the three AcceptLanguage classes.
whiteroses 5247679
Add create_accept_language_header().
whiteroses 115cee2
Turn re-usable code into function.
whiteroses 1fa105d
Add __add__ and __radd__ for AcceptLanguageValidHeader, with tests.
whiteroses a49b1b2
Add __add__ and __radd__ for AcceptLanguageNoHeader, with tests.
whiteroses 9f59da5
Add __add__ and __radd__ for AcceptLanguageInvalidHeader, with tests.
whiteroses d52159f
Add blank line.
whiteroses 3b23a87
Add docstrings for NoHeader's and InvalidHeader's __str__s.
whiteroses 3ca3602
Update documentation.
whiteroses c9d132b
Test NoHeader and InvalidHeader rather than InvalidOrNoHeader.
whiteroses d558edf
Add accept_language_property and tests.
whiteroses 2febfa1
Use accept_language_property in request.
whiteroses 5292e2e
Update AcceptLanguage class, and stop inheriting from Accept.
whiteroses ad9c288
Remove HeaderClass attribute, which we no longer need.
whiteroses e73ea05
Make test methods' names and order consistent.
whiteroses ca4e613
Assert that all three subclasses are instances of AcceptLanguage.
whiteroses 3b1fbcb
Add a blank line after docstrings documenting classes.
whiteroses 09c12ed
Remove :inherited-members: option.
whiteroses 8b9a39a
Make docstring a raw string.
whiteroses 3cae8fe
Add deprecation warnings for __iter__.
whiteroses 2074517
Fix wording.
whiteroses 84a8fd7
Add tests for AcceptLanguageValidHeader.best_match.
whiteroses 531e63e
Add tests for ...NoHeader.best_match and ...InvalidHeader.best_match.
whiteroses 569d1a4
Add tests for .quality().
whiteroses 38f8a8d
Remove check for 'q'.
whiteroses 0a5cd70
Add tests for Accept.__iter__ and NilAccept.__iter__.
whiteroses b69ceab
Remove :members: option.
whiteroses 949ceb4
Make .header_value and .parsed read-only properties.
whiteroses 47809be
Set autodoc_member_order.
whiteroses 0e69548
Change variable name from ``accept_language`` to ``instance``.
whiteroses a47db23
Make AcceptLanguageInvalidHeader.__repr__ safer.
whiteroses 7622489
Make AcceptLanguageValidHeader.__repr__ safer.
whiteroses 1c6dbaf
Make __repr__ consistent between the AcceptLanguage classes.
whiteroses f591272
Stop displaying header_value in AcceptLanguageValidHeader.__repr__.
whiteroses 1bf58d9
Improve comment.
whiteroses faab81b
Change double quotes to single quotes for consistency.
whiteroses ecf671f
Remove comment.
whiteroses 0967b02
Remove unnecessary blank lines.
whiteroses 1de163f
Improve __repr__ of AcceptLanguage classes.
whiteroses ccc02e8
Add functions to help with forming the regexes for parsing the headers.
whiteroses e9e911c
Remove note on parsing.
whiteroses 2998875
Remove unnecessary ``else:``.
whiteroses c825cc1
Change 'generator' to 'generator iterator' to avoid ambiguity.
whiteroses 7866f75
Use more helpful variable names.
whiteroses eceb488
Raise ValueError with error message.
whiteroses 8abc5aa
Change 'generator iterator' to 'iterator' in docstring.
whiteroses f003cd8
Change test imports to module scope.
whiteroses 82df771
Add spaces.
whiteroses 2f293c7
Treat invalid header values like ``NoHeader``s when __add__ing.
whiteroses 55d3233
Remove unused `default_quality` parameter.
whiteroses 54bcba3
Fix missing commas and spacing in single-element tuples.
whiteroses 9e04492
Correct and improve wording of docstrings.
whiteroses eaf0d5b
Improve wording in docstring.
whiteroses 259b497
Simplify regexes.
whiteroses ea3e9ef
Add underscore to classmethod to make it clear that it's not public API.
whiteroses 7470666
Change PendingDeprecationWarnings to DeprecationWarnings.
whiteroses c2c3bdf
Check and raise instead of using asserts.
whiteroses 6d7ffe8
Remove undocumented `modifier` parameter.
whiteroses f365864
Remove unnecessary blank line.
whiteroses e884501
Move .parse from AcceptLanguageValidHeader to AcceptLanguage.
whiteroses 20bb604
Update to say AcceptLanguageValidHeader._old_match will be deprecated.
whiteroses 218a7f2
Fix typo.
whiteroses a11a6ed
Add missing word.
whiteroses 1916764
Fix incorrect test.
whiteroses File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Can we remove the subclasses from the public api now?
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.
We can if we combine the docstrings for all the subclasses for each method and put them all into
AcceptLanguage
. This would imo make some already complicated docstrings even more complicated, adding another layer to the branching. And as I mentioned before, the instances would still i.d. as the subclasses (I guess we could change the__repr__
to indicate that it is a subclass ofAcceptLanguage
, so people would know to look there?) If you want me to go ahead and make the change, I will — it's not trivial, and will take some time and thought on how to combine the docstrings from the three subclasses for each method. (I would also have to do the same for the other three headers.)Would it be possible to merge this so I can push changes for this and the other three headers before the deadline tomorrow to a more appropriately-named PR, or should I push the changes for all four headers to this one?
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's fine if we want to merge this now. I'm happy with that.
Part of the idea of making the subclasses "hidden" is not that people don't know about them but that they don't care. I'm more worried about the docs the user sees than the actual objects they see in the repl. With that in mind we'd want to make the docstrings focus on valid headers with just a sentence or two in each that explains what happens with invalid/missing data. I can't imagine that will make the docstrings that much more complex or harder to parse but I could be wrong!
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 was worrying whether it would be clear enough that people should look at the docs for
AcceptLanguage
if the objects identify as the subclasses, but I understand what you are looking for, and will try to combine the docstrings and document one api under the base class after I've finished wrapping up the four headers and all the necessary submissions for gsoc. Could you please merge this PR if everything is ok, so I can open a new PR and push the other changes? (Sorry about the last-minute commits, they are minor changes to fix small mistakes.) Thanks!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 again @whiteroses I'm happy with all of this.
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.
Alright, any future work can be done in a different PR.