Fixing stubtest issues (#5339)

* Fix stubtest issues
This commit is contained in:
hatal175
2021-05-05 17:23:43 +03:00
committed by GitHub
parent 8379386bd4
commit 461791db27
16 changed files with 96 additions and 97 deletions

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, Union, overload
from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, Optional, TypeVar, Union, overload
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -35,6 +35,10 @@ def copy_context() -> Context: ...
# a different value.
class Context(Mapping[ContextVar[Any], Any]):
def __init__(self) -> None: ...
@overload
def get(self, __key: ContextVar[Any]) -> Optional[Any]: ...
@overload
def get(self, __key: ContextVar[Any], __default: Optional[Any]) -> Any: ...
def run(self, callable: Callable[..., _T], *args: Any, **kwargs: Any) -> _T: ...
def copy(self) -> Context: ...
def __getitem__(self, key: ContextVar[Any]) -> Any: ...

View File

@@ -183,18 +183,33 @@ class HTTPConnection:
def send(self, data: _DataType) -> None: ...
class HTTPSConnection(HTTPConnection):
def __init__(
self,
host: str,
port: Optional[int] = ...,
key_file: Optional[str] = ...,
cert_file: Optional[str] = ...,
timeout: Optional[float] = ...,
source_address: Optional[Tuple[str, int]] = ...,
*,
context: Optional[ssl.SSLContext] = ...,
check_hostname: Optional[bool] = ...,
) -> None: ...
if sys.version_info >= (3, 7):
def __init__(
self,
host: str,
port: Optional[int] = ...,
key_file: Optional[str] = ...,
cert_file: Optional[str] = ...,
timeout: Optional[float] = ...,
source_address: Optional[Tuple[str, int]] = ...,
*,
context: Optional[ssl.SSLContext] = ...,
check_hostname: Optional[bool] = ...,
blocksize: int = ...,
) -> None: ...
else:
def __init__(
self,
host: str,
port: Optional[int] = ...,
key_file: Optional[str] = ...,
cert_file: Optional[str] = ...,
timeout: Optional[float] = ...,
source_address: Optional[Tuple[str, int]] = ...,
*,
context: Optional[ssl.SSLContext] = ...,
check_hostname: Optional[bool] = ...,
) -> None: ...
class HTTPException(Exception): ...

View File

@@ -63,21 +63,39 @@ class DefaultCookiePolicy(CookiePolicy):
DomainRFC2965Match: int
DomainLiberal: int
DomainStrict: int
def __init__(
self,
blocked_domains: Optional[Sequence[str]] = ...,
allowed_domains: Optional[Sequence[str]] = ...,
netscape: bool = ...,
rfc2965: bool = ...,
rfc2109_as_netscape: Optional[bool] = ...,
hide_cookie2: bool = ...,
strict_domain: bool = ...,
strict_rfc2965_unverifiable: bool = ...,
strict_ns_unverifiable: bool = ...,
strict_ns_domain: int = ...,
strict_ns_set_initial_dollar: bool = ...,
strict_ns_set_path: bool = ...,
) -> None: ...
if sys.version_info >= (3, 8):
def __init__(
self,
blocked_domains: Optional[Sequence[str]] = ...,
allowed_domains: Optional[Sequence[str]] = ...,
netscape: bool = ...,
rfc2965: bool = ...,
rfc2109_as_netscape: Optional[bool] = ...,
hide_cookie2: bool = ...,
strict_domain: bool = ...,
strict_rfc2965_unverifiable: bool = ...,
strict_ns_unverifiable: bool = ...,
strict_ns_domain: int = ...,
strict_ns_set_initial_dollar: bool = ...,
strict_ns_set_path: bool = ...,
secure_protocols: Sequence[str] = ...,
) -> None: ...
else:
def __init__(
self,
blocked_domains: Optional[Sequence[str]] = ...,
allowed_domains: Optional[Sequence[str]] = ...,
netscape: bool = ...,
rfc2965: bool = ...,
rfc2109_as_netscape: Optional[bool] = ...,
hide_cookie2: bool = ...,
strict_domain: bool = ...,
strict_rfc2965_unverifiable: bool = ...,
strict_ns_unverifiable: bool = ...,
strict_ns_domain: int = ...,
strict_ns_set_initial_dollar: bool = ...,
strict_ns_set_path: bool = ...,
) -> None: ...
def blocked_domains(self) -> Tuple[str, ...]: ...
def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ...
def is_blocked(self, domain: str) -> bool: ...

View File

@@ -82,7 +82,7 @@ class _NNTPBase:
def ihave(self, message_id: Any, data: Union[bytes, Iterable[bytes]]) -> str: ...
def quit(self) -> str: ...
def login(self, user: Optional[str] = ..., password: Optional[str] = ..., usenetrc: bool = ...) -> None: ...
def starttls(self, ssl_context: Optional[ssl.SSLContext] = ...) -> None: ...
def starttls(self, context: Optional[ssl.SSLContext] = ...) -> None: ...
class NNTP(_NNTPBase):
port: int

View File

@@ -1,6 +1,6 @@
import sys
if sys.version_info < (3, 9):
if sys.version_info < (3, 8):
import os
DEV_NULL = os.devnull

View File

@@ -2,7 +2,7 @@ from email.message import Message as _Message
from socket import socket
from ssl import SSLContext
from types import TracebackType
from typing import Any, Dict, List, Optional, Pattern, Protocol, Sequence, Tuple, Type, Union, overload
from typing import Any, Dict, Optional, Pattern, Protocol, Sequence, Tuple, Type, Union, overload
_Reply = Tuple[int, bytes]
_SendErrs = Dict[str, _Reply]
@@ -117,7 +117,7 @@ class SMTP:
to_addrs: Union[str, Sequence[str]],
msg: Union[bytes, str],
mail_options: Sequence[str] = ...,
rcpt_options: List[str] = ...,
rcpt_options: Sequence[str] = ...,
) -> _SendErrs: ...
def send_message(
self,

View File

@@ -1,3 +1,4 @@
import sys
from typing import Any, Dict, List, Optional, Union
MAGIC: int
@@ -72,7 +73,10 @@ REPEAT: _NamedIntConstant
REPEAT_ONE: _NamedIntConstant
SUBPATTERN: _NamedIntConstant
MIN_REPEAT_ONE: _NamedIntConstant
RANGE_IGNORE: _NamedIntConstant
if sys.version_info >= (3, 7):
RANGE_UNI_IGNORE: _NamedIntConstant
else:
RANGE_IGNORE: _NamedIntConstant
MIN_REPEAT: _NamedIntConstant
MAX_REPEAT: _NamedIntConstant

View File

@@ -38,7 +38,7 @@ class BackgroundBrowser(GenericBrowser):
def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ...
class UnixBrowser(BaseBrowser):
raise_opts: List[str]
raise_opts: Optional[List[str]]
background: bool
redirect_stdout: bool
remote_args: List[str]
@@ -70,7 +70,6 @@ class Chrome(UnixBrowser):
background: bool
class Opera(UnixBrowser):
raise_opts: List[str]
remote_args: List[str]
remote_action: str
remote_action_newwin: str

View File

@@ -1,4 +1,4 @@
ctypes.wintypes
pwd.getpwnam
time.CLOCK_PROF
time.CLOCK_UPTIME
time.CLOCK_UPTIME

View File

@@ -2,4 +2,4 @@ ctypes.wintypes
os.MFD_HUGE_32MB
os.MFD_HUGE_512MB
time.CLOCK_PROF
time.CLOCK_UPTIME
time.CLOCK_UPTIME

View File

@@ -38,9 +38,7 @@ collections.abc.ItemsView.__reversed__
collections.abc.KeysView.__reversed__
collections.abc.ValuesView.__reversed__
contextlib.nullcontext # not a function at runtime
contextvars.Context.__init__
contextvars.Context.get
copy.PyStringMap
contextvars.Context.__init__ # Default C __init__ signature is wrong
curses.color_pair
dataclasses.field
dummy_threading
@@ -53,9 +51,7 @@ functools.singledispatchmethod.__call__
gettext.install
gettext.translation
hmac.new # Stub is a white lie; see comments in the stub
http.client.HTTPSConnection.__init__
http.cookiejar.DefaultCookiePolicy.__init__
http.server.SimpleHTTPRequestHandler.__init__
http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded
importlib.abc.Traversable.__init__ # Inherits __init__ from typing.Protocol
ipaddress.IPv4Interface.hostmask
ipaddress.IPv6Interface.hostmask
@@ -70,19 +66,16 @@ macpath # module removed in 3.8
macurl2path # module removed in 3.7
mmap.MADV_[A-Z_]+ # platform dependent constants
multiprocessing.spawn._main
nntplib.NNTP.starttls
os.getgrouplist
os.sendfile
pickle.Pickler.reducer_override
pickle.Pickler.reducer_override # implemented in C pickler
# platform.uname_result's processor field is now dynamically made to exist
platform.uname_result.__new__
platform.uname_result._fields
platform.uname_result.processor
queue.SimpleQueue.__init__
queue.SimpleQueue.__init__ # Default C __init__ signature is wrong
select.epoll.register
smtplib.LMTP.__init__
smtplib.SMTP.sendmail
sre_constants.RANGE_IGNORE
ssl.PROTOCOL_SSLv3 # Depends on ssl compilation
ssl.RAND_egd # Depends on openssl compilation
symtable.SymbolTable.has_exec
@@ -114,7 +107,6 @@ typing._TypedDict.setdefault
typing._TypedDict.update
typing._TypedDict.values
weakref.WeakValueDictionary.update
webbrowser.Opera.raise_opts
xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signature
xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signature

View File

@@ -20,7 +20,6 @@ collections.AsyncGenerator.ag_frame
collections.AsyncGenerator.ag_running
collections.UserString.maketrans
contextlib._GeneratorContextManager.__init__
copy.PyStringMap
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
hmac.HMAC.__init__
@@ -31,7 +30,6 @@ ipaddress._BaseNetwork.__init__
json.loads
mmap.ACCESS_DEFAULT
multiprocessing.shared_memory
nntplib._NNTPBase.starttls
os.utime
plistlib.Dict.__init__
pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
@@ -39,7 +37,6 @@ random.Random.randrange # missing undocumented arg _int
random.randrange # missing undocumented arg _int
sched.Event.__doc__ # __slots__ is overridden
secrets.SystemRandom.getstate
smtplib.SMTP.sendmail
sre_compile.dis
typing.AsyncGenerator.ag_await
typing.AsyncGenerator.ag_code
@@ -67,7 +64,6 @@ unittest.async_case # Added in Python 3.8
urllib.parse.parse_qs
urllib.parse.parse_qsl
uuid.UUID.int
webbrowser.Opera.raise_opts
xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495
xml.etree.cElementTree.TreeBuilder.start # bpo-39495
xml.parsers.expat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args

View File

@@ -25,32 +25,26 @@ collections.abc.AsyncGenerator.ag_code
collections.abc.AsyncGenerator.ag_frame
collections.abc.AsyncGenerator.ag_running
concurrent.futures.ProcessPoolExecutor.map
contextvars.Context.__init__
contextvars.Context.get
contextvars.Context.__init__ # Default C __init__ signature is wrong
contextvars.ContextVar.get
contextlib.nullcontext # not a function at runtime
copy.PyStringMap
dataclasses.field
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
hmac.HMAC.__init__
http.client.HTTPSConnection.__init__
http.server.SimpleHTTPRequestHandler.__init__
http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded
importlib.metadata # Added in 3.8
ipaddress._BaseNetwork.__init__
json.loads
macurl2path # removed in 3.7
multiprocessing.shared_memory
nntplib._NNTPBase.starttls
os.utime
pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
queue.SimpleQueue.__init__
queue.SimpleQueue.__init__ # Default C __init__ signature is wrong
random.Random.randrange # missing undocumented arg _int
random.randrange # missing undocumented arg _int
sched.Event.__doc__ # __slots__ is overridden
secrets.SystemRandom.getstate
smtplib.SMTP.sendmail
sre_constants.RANGE_IGNORE
ssl.PROTOCOL_SSLv3 # Depends on ssl compilation
ssl.RAND_egd # Depends on openssl compilation
types.ClassMethodDescriptorType.__get__
@@ -68,7 +62,6 @@ urllib.parse.parse_qsl
uuid.UUID.int
uuid.UUID.is_safe
uuid.getnode # undocumented, unused parameter getters that was later removed
webbrowser.Opera.raise_opts
xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495
xml.etree.cElementTree.TreeBuilder.start # bpo-39495
xml.parsers.expat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args

View File

@@ -5,10 +5,6 @@ _collections_abc.AsyncGenerator.ag_running
_collections_abc.ItemsView.__reversed__
_collections_abc.KeysView.__reversed__
_collections_abc.ValuesView.__reversed__
# This was changed in Python 3.8.8.
_curses.color_pair
_thread.ExceptHookArgs
_thread._ExceptHookArgs
ast.Bytes.__new__
ast.Ellipsis.__new__
ast.NameConstant.__new__
@@ -40,41 +36,31 @@ collections.abc.KeysView.__reversed__
collections.abc.ValuesView.__reversed__
concurrent.futures.ProcessPoolExecutor.map
contextlib.nullcontext # not a function at runtime
contextvars.Context.__init__
contextvars.Context.get
copy.PyStringMap
# This was changed in Python 3.8.8.
curses.color_pair
contextvars.Context.__init__ # Default C __init__ signature is wrong
dataclasses.field
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
functools.partialmethod.__get__
functools.singledispatchmethod.__call__ # A lie to reflect that the descriptor get returns a callable
gettext.install
gettext.translation
gettext.install # codeset default value is ['unspecified'] so can't be specified
gettext.translation # codeset default value is ['unspecified'] so can't be specified
hmac.new # Stub is a white lie; see comments in the stub
http.client.HTTPSConnection.__init__
http.cookiejar.DefaultCookiePolicy.__init__
http.server.SimpleHTTPRequestHandler.__init__
http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded
ipaddress.IPv4Interface.hostmask
ipaddress.IPv6Interface.hostmask
ipaddress._BaseNetwork.broadcast_address
ipaddress._BaseNetwork.hostmask
macpath
macpath # removed in 3.8
macurl2path # removed in 3.7
mmap.MADV_[A-Z_]+
multiprocessing.spawn._main
nntplib._NNTPBase.starttls
pickle.Pickler.reducer_override
platform.DEV_NULL
queue.SimpleQueue.__init__
pickle.Pickler.reducer_override # implemented in C pickler
queue.SimpleQueue.__init__ # Default C __init__ signature is wrong
random.Random.randrange # missing undocumented arg _int
random.randrange # missing undocumented arg _int
sched.Event.__doc__ # __slots__ is overridden
secrets.SystemRandom.getstate
select.epoll.register
smtplib.SMTP.sendmail
sre_constants.RANGE_IGNORE
ssl.PROTOCOL_SSLv3 # Depends on ssl compilation
ssl.RAND_egd # Depends on openssl compilation
sys.UnraisableHookArgs # Not exported from sys
@@ -97,7 +83,6 @@ typing._SpecialForm.__init__
typing._SpecialForm.__new__
uuid.getnode # undocumented, unused parameter getters that was later removed
weakref.WeakValueDictionary.update
webbrowser.Opera.raise_opts
xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495
xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signature
xml.etree.cElementTree.TreeBuilder.start # bpo-39495

View File

@@ -46,9 +46,7 @@ collections.abc.ItemsView.__reversed__
collections.abc.KeysView.__reversed__
collections.abc.ValuesView.__reversed__
contextlib.nullcontext # not a function at runtime
contextvars.Context.__init__
contextvars.Context.get
copy.PyStringMap
contextvars.Context.__init__ # Default C __init__ signature is wrong
curses.color_pair
dataclasses.field
dataclasses.InitVar.__class_getitem__ # stubtest bug. doesn't do the right thing with overload + implicit classmethod __class_getitem__
@@ -62,9 +60,7 @@ functools.singledispatchmethod.__call__
gettext.install
gettext.translation
hmac.new # Stub is a white lie; see comments in the stub
http.client.HTTPSConnection.__init__
http.cookiejar.DefaultCookiePolicy.__init__
http.server.SimpleHTTPRequestHandler.__init__
http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded
importlib.abc.Traversable.__init__ # Inherits __init__ from typing.Protocol
ipaddress.IPv4Interface.hostmask
ipaddress.IPv6Interface.hostmask
@@ -79,23 +75,20 @@ macpath # module removed in 3.8
macurl2path # module removed in 3.7
mmap.MADV_[A-Z_]+ # platform dependent constants
multiprocessing.spawn._main
nntplib.NNTP.starttls
os.MFD_HUGE_32MB
os.MFD_HUGE_512MB
os.getgrouplist
os.sendfile
pickle.Pickler.reducer_override
pickle.Pickler.reducer_override # implemented in C pickler
# platform.uname_result's processor field is now dynamically made to exist
platform.uname_result.__new__
platform.uname_result._fields
platform.uname_result.processor
queue.SimpleQueue.__init__
queue.SimpleQueue.__init__ # Default C __init__ signature is wrong
sched.Event.__doc__ # __slots__ is overridden
secrets.SystemRandom.getstate
select.epoll.register
smtplib.LMTP.__init__
smtplib.SMTP.sendmail
sre_constants.RANGE_IGNORE
ssl.PROTOCOL_SSLv3 # Depends on ssl compilation
ssl.RAND_egd # Depends on openssl compilation
symtable.SymbolTable.has_exec
@@ -128,7 +121,6 @@ typing._TypedDict.update
typing._TypedDict.values
unittest.doModuleCleanups
weakref.WeakValueDictionary.update
webbrowser.Opera.raise_opts
xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signature
xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signature

View File

@@ -66,6 +66,7 @@ configparser.SectionProxy.__getattr__ # SectionProxy can have arbitrary attribu
configparser.SectionProxy.getboolean
configparser.SectionProxy.getfloat
configparser.SectionProxy.getint
copy.PyStringMap # defined only in Jython
# The Dialect properties are initialized as None in Dialect but their values are enforced in _Dialect
csv.Dialect.delimiter
csv.Dialect.doublequote