Modernize syntax in various stubs (#7469)

Use `str` and `contextlib.AbstractContextManager` instead of `typing.Text` and `typing.ContextManager`.
This commit is contained in:
Alex Waygood
2022-03-09 21:23:26 +00:00
committed by GitHub
parent cdb573b398
commit 9a1f5fb06c
16 changed files with 197 additions and 202 deletions

View File

@@ -1,9 +1,7 @@
from typing import Text
class InvalidToken(Exception): ...
class Fernet:
def __init__(self, key: bytes | Text) -> None: ...
def __init__(self, key: bytes | str) -> None: ...
def decrypt(self, token: bytes, ttl: int | None = ...) -> bytes: ...
# decrypt_at_time accepts None ttl at runtime but it's an implementtion detail and it doesn't really
# make sense for the client code to use it like that, so the parameter is typed as int as opposed to

View File

@@ -3,7 +3,7 @@ from _typeshed import Self
from abc import ABCMeta, abstractmethod
from enum import Enum
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
from typing import Any, ClassVar, Generator, Generic, Iterable, Sequence, Text, TypeVar
from typing import Any, ClassVar, Generator, Generic, Iterable, Sequence, TypeVar
from cryptography.hazmat.backends.interfaces import X509Backend
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
@@ -108,8 +108,8 @@ class ExtendedKeyUsageOID:
class NameAttribute:
oid: ObjectIdentifier
value: Text
def __init__(self, oid: ObjectIdentifier, value: Text) -> None: ...
value: str
def __init__(self, oid: ObjectIdentifier, value: str) -> None: ...
def rfc4514_string(self) -> str: ...
class RelativeDistinguishedName:
@@ -254,8 +254,8 @@ class DirectoryName(GeneralName):
def __init__(self, value: Name) -> None: ...
class DNSName(GeneralName):
value: Text
def __init__(self, value: Text) -> None: ...
value: str
def __init__(self, value: str) -> None: ...
class IPAddress(GeneralName):
value: IPv4Address | IPv6Address | IPv4Network | IPv6Network
@@ -271,12 +271,12 @@ class RegisteredID(GeneralName):
def __init__(self, value: ObjectIdentifier) -> None: ...
class RFC822Name(GeneralName):
value: Text
def __init__(self, value: Text) -> None: ...
value: str
def __init__(self, value: str) -> None: ...
class UniformResourceIdentifier(GeneralName):
value: Text
def __init__(self, value: Text) -> None: ...
value: str
def __init__(self, value: str) -> None: ...
# X.509 Extensions