Use MaybeNone (alias to Any) when applicable (#12855)

This commit is contained in:
Oleh Prypin
2024-10-18 23:07:52 +02:00
committed by GitHub
parent 7fb84668fc
commit b2f68ec2fe
10 changed files with 43 additions and 41 deletions

View File

@@ -3,10 +3,10 @@ import io
import ssl
import sys
import types
from _typeshed import ReadableBuffer, SupportsRead, SupportsReadline, WriteableBuffer
from _typeshed import MaybeNone, ReadableBuffer, SupportsRead, SupportsReadline, WriteableBuffer
from collections.abc import Callable, Iterable, Iterator, Mapping
from socket import socket
from typing import Any, BinaryIO, TypeVar, overload
from typing import BinaryIO, TypeVar, overload
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -154,7 +154,7 @@ class HTTPConnection:
timeout: float | None
host: str
port: int
sock: socket | Any # can be `None` if `.connect()` was not called
sock: socket | MaybeNone # can be `None` if `.connect()` was not called
def __init__(
self,
host: str,
@@ -187,7 +187,7 @@ class HTTPConnection:
class HTTPSConnection(HTTPConnection):
# Can be `None` if `.connect()` was not called:
sock: ssl.SSLSocket | Any
sock: ssl.SSLSocket | MaybeNone
if sys.version_info >= (3, 12):
def __init__(
self,