Add stubs for WebOb (#9874)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
David Salvisberg
2023-06-18 16:32:49 +02:00
committed by GitHub
parent 7544b60db7
commit df795220a3
20 changed files with 1854 additions and 0 deletions

View File

@@ -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