-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add stubs for WebOb #9874
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
Merged
Add stubs for WebOb #9874
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
46ebabc
Add stubs for WebOb
Daverball 5c9868a
Fixes up some issues reported by pyright and pytype
Daverball a0dd49d
Merge remote-tracking branch 'upstream/main' into webob
Daverball f9470bc
Fixes a couple of additional issues
Daverball ca38af6
Makes stubtest happy
Daverball 10c53c7
Fixes `webob.request.NoDefault` annotation
Daverball 45eaa9d
Adds comments to the allowlist
Daverball f53e00c
Adds some missing type annotations and fixes issues uncovered in testing
Daverball 0895b80
Gets rid of string type complexity that was removed upstream
Daverball b0770d1
Finishes up exc module. Missed a couple of easy `Incomplete`s.
Daverball 5770e4d
Switches to typeshed's wsgi types
Daverball c56a005
Consistently uses `WSGIEnvironment` wherever appropriate
Daverball 69a4c14
Runs stubdefaulter
Daverball 2e2d682
Fixes broken overload for `lookup` method in `Webob.acceptparse`
Daverball 944afe7
Merge remote-tracking branch 'upstream/main' into webob
Daverball 17c51c3
Fixes up acceptparse module. Adds a couple of overlooked annotations.
Daverball 71b4609
Merge branch 'main' into webob
AlexWaygood 7f0f743
Apply suggestions from code review
Daverball b5ca284
Fixes missing `@wsgify` in `__call__` methods in `webob.static`
Daverball 6c1f699
Gets rid of `NoReturn` in `webob.multidict`.
Daverball de30e65
Gets rid of the remaining two uses of `NoReturn`
Daverball 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
# Error: is not present in stub | ||
# ============================= | ||
# These are plain strings, regex strings or compiled regex patterns | ||
# which are used internally for parsing, so they should not be public API | ||
webob.acceptparse.Accept.accept_compiled_re | ||
webob.acceptparse.Accept.accept_ext_compiled_re | ||
webob.acceptparse.Accept.accept_ext_re | ||
webob.acceptparse.Accept.accept_params_re | ||
webob.acceptparse.Accept.media_range_n_accept_params_compiled_re | ||
webob.acceptparse.Accept.media_range_n_accept_params_re | ||
webob.acceptparse.Accept.media_range_re | ||
webob.acceptparse.Accept.media_type_compiled_re | ||
webob.acceptparse.Accept.media_type_re | ||
webob.acceptparse.Accept.obs_text_re | ||
webob.acceptparse.Accept.parameter_re | ||
webob.acceptparse.Accept.parameters_compiled_re | ||
webob.acceptparse.Accept.qdtext_re | ||
webob.acceptparse.Accept.quoted_pair_re | ||
webob.acceptparse.Accept.quoted_string_re | ||
webob.acceptparse.Accept.subtype_re | ||
webob.acceptparse.Accept.type_re | ||
webob.acceptparse.Accept.vchar_re | ||
webob.acceptparse.AcceptCharset.accept_charset_compiled_re | ||
webob.acceptparse.AcceptCharset.charset_n_weight_compiled_re | ||
webob.acceptparse.AcceptCharset.charset_n_weight_re | ||
webob.acceptparse.AcceptCharset.charset_re | ||
webob.acceptparse.AcceptEncoding.accept_encoding_compiled_re | ||
webob.acceptparse.AcceptEncoding.codings_n_weight_compiled_re | ||
webob.acceptparse.AcceptEncoding.codings_n_weight_re | ||
webob.acceptparse.AcceptEncoding.codings_re | ||
webob.acceptparse.AcceptLanguage.accept_language_compiled_re | ||
webob.acceptparse.AcceptLanguage.lang_range_n_weight_compiled_re | ||
webob.acceptparse.AcceptLanguage.lang_range_n_weight_re | ||
webob.acceptparse.AcceptLanguage.lang_range_re | ||
webob.acceptparse.OWS_re | ||
webob.acceptparse.qvalue_re | ||
webob.acceptparse.tchar_re | ||
webob.acceptparse.token_compiled_re | ||
webob.acceptparse.token_re | ||
webob.acceptparse.weight_re | ||
webob.cachecontrol.need_quote_re | ||
webob.cachecontrol.token_re | ||
webob.client.SendRequest.MULTILINE_RE | ||
webob.descriptors.CHARSET_RE | ||
webob.descriptors.SCHEME_RE | ||
|
||
webob.acceptparse.MIMEAccept # Deprecated API | ||
|
||
# PY2 compat stuff that has already been removed upstream | ||
webob.compat | ||
webob.multidict.MultiDict.iteritems | ||
webob.multidict.MultiDict.iterkeys | ||
webob.multidict.MultiDict.itervalues | ||
webob.multidict.NestedMultiDict.iteritems | ||
webob.multidict.NestedMultiDict.iterkeys | ||
webob.multidict.NestedMultiDict.itervalues | ||
webob.multidict.NoVars.iterkeys | ||
|
||
# NoVars implements the MultiDict interface for better runtime errors | ||
# but it is annoying for type checking, so the methods that are not | ||
# valid to call on NoVars have been removed. In the future we would | ||
# like to switch to a @type_error() decorator | ||
webob.multidict.NoVars.__getitem__ | ||
webob.multidict.NoVars.__setitem__ | ||
webob.multidict.NoVars.__delitem__ | ||
webob.multidict.NoVars.add | ||
webob.multidict.NoVars.setdefault | ||
webob.multidict.NoVars.update | ||
webob.multidict.NoVars.clear | ||
webob.multidict.NoVars.pop | ||
webob.multidict.NoVars.popitem | ||
webob.multidict.NoVars.getone | ||
|
||
# ResponseBodyFile cannot be closed and emits an Exception, so we're better | ||
# off pretending the method doesn't exist | ||
webob.response.ResponseBodyFile.close | ||
|
||
# Error: is inconsistent | ||
# ====================== | ||
# set_cookie has a deprecated argument `expires` which has been removed upstream | ||
webob.Response.set_cookie | ||
webob.response.Response.set_cookie | ||
|
||
# These methods have been moved from their subclasses to the shared hidden superclass | ||
# since the method signatures are the same, so this saves some copy pasta and should | ||
# not affect type checking or runtime behavior in any way | ||
webob.acceptparse._AcceptCharsetInvalidOrNoHeader.__add__ | ||
webob.acceptparse._AcceptCharsetInvalidOrNoHeader.__radd__ | ||
webob.acceptparse._AcceptCharsetInvalidOrNoHeader.copy | ||
webob.acceptparse._AcceptCharsetInvalidOrNoHeader.parsed | ||
webob.acceptparse._AcceptEncodingInvalidOrNoHeader.__add__ | ||
webob.acceptparse._AcceptEncodingInvalidOrNoHeader.__radd__ | ||
webob.acceptparse._AcceptEncodingInvalidOrNoHeader.copy | ||
webob.acceptparse._AcceptEncodingInvalidOrNoHeader.parsed | ||
webob.acceptparse._AcceptInvalidOrNoHeader.__add__ | ||
webob.acceptparse._AcceptInvalidOrNoHeader.__radd__ | ||
webob.acceptparse._AcceptInvalidOrNoHeader.copy | ||
webob.acceptparse._AcceptInvalidOrNoHeader.parsed | ||
webob.acceptparse._AcceptLanguageInvalidOrNoHeader.__add__ | ||
webob.acceptparse._AcceptLanguageInvalidOrNoHeader.__radd__ | ||
webob.acceptparse._AcceptLanguageInvalidOrNoHeader.copy | ||
webob.acceptparse._AcceptLanguageInvalidOrNoHeader.lookup | ||
webob.acceptparse._AcceptLanguageInvalidOrNoHeader.parsed | ||
|
||
# These are here due to the slightly more strict nature of the type annotation | ||
# of these descriptors for type checking, it does not really have any runtime | ||
# consequences since `_IntValueProperty` derives from `value_property` and | ||
# only makes `__set__` slightly more strict. | ||
webob.cachecontrol.CacheControl.max_age | ||
webob.cachecontrol.CacheControl.max_stale | ||
webob.cachecontrol.CacheControl.min_fresh | ||
webob.cachecontrol.CacheControl.s_max_age | ||
webob.cachecontrol.CacheControl.s_maxage | ||
webob.cachecontrol.CacheControl.stale_if_error | ||
webob.cachecontrol.CacheControl.stale_while_revalidate | ||
webob.cachecontrol.CacheControl.update_dict | ||
webob.cachecontrol.UpdateDict.setdefault | ||
|
||
# These need to be ignored due to how WebOb decided to let people know | ||
# that certain methods on `NestedMultiDict` should not be called since | ||
# they are immutable, compared to a MultiDict, but still can be used | ||
# interchangeably in some parts of the API. So they re-use generic functions | ||
# that accept any parameters and assign them to methods which should still | ||
# satisfy the same interface. The type annotations enforce the correct | ||
# input arguments instead of the generic ones. | ||
webob.multidict.NestedMultiDict.popitem | ||
webob.multidict.NestedMultiDict.clear | ||
|
||
# The `DEFAULT` parameter on these dunder methods don't really make sense as | ||
# part of the public API, so they have been removed from the stubs | ||
webob.request.AdhocAttrMixin.__delattr__ | ||
webob.request.AdhocAttrMixin.__getattr__ | ||
webob.request.AdhocAttrMixin.__setattr__ | ||
|
||
# BaseRequest has a bunch of named parameters that have been deprecated and | ||
# removed upstream, since there's a `**kwargs` anyways, it doesn't really | ||
# make sense to annotate them and pretend they're part of the API. | ||
webob.request.BaseRequest.__init__ | ||
|
||
# Error: is not present at runtime | ||
# ============================= | ||
# This attribute is there to help mypy type narrow NoVars based on its static | ||
# falsyness, so it's to make it possible to narrow the type union in request.POST | ||
# without importing MultiDict or NoVars | ||
webob.multidict.NoVars.__bool__ | ||
|
||
# This attribute is set on the instance instead of the class in the `__init__` | ||
# so the type annotation is technically wrong, however I am unsure about | ||
# whether the ResponseBodyFile would satisfy some of the IO Protocols if | ||
# `write` was defined as a Callable instance attribute. It's hard to come up | ||
# with a use-case where the distinction matters, besides inherting from | ||
# the class and overwriting the __init__ and forgetting to populate `write`. | ||
webob.response.ResponseBodyFile.write |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version = "1.8.*" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from webob.datetime_utils import ( | ||
UTC as UTC, | ||
day as day, | ||
hour as hour, | ||
minute as minute, | ||
month as month, | ||
second as second, | ||
week as week, | ||
year as year, | ||
) | ||
from webob.request import LegacyRequest as LegacyRequest, Request as Request | ||
from webob.response import Response as Response | ||
from webob.util import html_escape as html_escape |
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.