mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-06 13:10:22 +03:00
Self type support in Python 3.8-3.10
This commit is contained in:
parent
86d41e1f06
commit
2fcb734b98
|
@ -22,6 +22,7 @@ dependencies = [
|
||||||
"pyaes~=1.6",
|
"pyaes~=1.6",
|
||||||
"rsa~=4.9",
|
"rsa~=4.9",
|
||||||
"markdown-it-py~=3.0",
|
"markdown-it-py~=3.0",
|
||||||
|
"typing-extensions~=4.12.2",
|
||||||
]
|
]
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import AsyncIterator
|
from collections.abc import AsyncIterator
|
||||||
from typing import TYPE_CHECKING, Optional, Self
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...session import PeerRef, UserRef
|
from ...session import PeerRef, UserRef
|
||||||
from ...tl import abcs, functions, types
|
from ...tl import abcs, functions, types
|
||||||
|
|
|
@ -4,7 +4,9 @@ import logging
|
||||||
from collections.abc import AsyncIterator, Awaitable, Callable
|
from collections.abc import AsyncIterator, Awaitable, Callable
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Any, Literal, Optional, Self, Sequence, Type, TypeVar
|
from typing import Any, Literal, Optional, Sequence, Type, TypeVar
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ....version import __version__ as default_version
|
from ....version import __version__ as default_version
|
||||||
from ...mtsender import Connector, Sender
|
from ...mtsender import Connector, Sender
|
||||||
|
|
|
@ -2,7 +2,9 @@ from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
from typing import TYPE_CHECKING, Literal, Optional, Self
|
from typing import TYPE_CHECKING, Literal, Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...session import ChannelRef, PeerRef
|
from ...session import ChannelRef, PeerRef
|
||||||
from ...tl import abcs, functions, types
|
from ...tl import abcs, functions, types
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
from typing import TYPE_CHECKING, Optional, Self
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import abcs
|
from ...tl import abcs
|
||||||
from ..types import NoPublicConstructor, Peer
|
from ..types import NoPublicConstructor, Peer
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Optional, Self, Sequence
|
from typing import TYPE_CHECKING, Optional, Sequence
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import abcs, types
|
from ...tl import abcs, types
|
||||||
from ..types import Message, Peer, expand_peer, peer_id
|
from ..types import Message, Peer, expand_peer, peer_id
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Optional, Self
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...session import PeerRef
|
from ...session import PeerRef
|
||||||
from ...tl import abcs, functions, types
|
from ...tl import abcs, functions, types
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import abc
|
import abc
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from typing import Any, Generic, Self, TypeVar
|
from typing import Any, Generic, TypeVar
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Optional, Self
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import abcs, types
|
from ...tl import abcs, types
|
||||||
from .draft import Draft
|
from .draft import Draft
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import TYPE_CHECKING, Optional, Self
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...session import PeerRef
|
from ...session import PeerRef
|
||||||
from ...tl import abcs, functions, types
|
from ...tl import abcs, functions, types
|
||||||
|
|
|
@ -6,7 +6,9 @@ from collections.abc import Coroutine
|
||||||
from inspect import isawaitable
|
from inspect import isawaitable
|
||||||
from io import BufferedWriter
|
from io import BufferedWriter
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Any, Optional, Protocol, Self, Sequence
|
from typing import TYPE_CHECKING, Any, Optional, Protocol, Sequence
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import abcs, types
|
from ...tl import abcs, types
|
||||||
from .meta import NoPublicConstructor
|
from .meta import NoPublicConstructor
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import types
|
from ...tl import types
|
||||||
from .meta import NoPublicConstructor
|
from .meta import NoPublicConstructor
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import types
|
from ...tl import types
|
||||||
from .meta import NoPublicConstructor
|
from .meta import NoPublicConstructor
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Optional, Self
|
from typing import Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import types
|
from ...tl import types
|
||||||
from .meta import NoPublicConstructor
|
from .meta import NoPublicConstructor
|
||||||
|
|
|
@ -2,7 +2,9 @@ from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING, Any, Optional, Self, Sequence, cast
|
from typing import TYPE_CHECKING, Any, Optional, Sequence, cast
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...session import PeerRef
|
from ...session import PeerRef
|
||||||
from ...tl import abcs, types
|
from ...tl import abcs, types
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import TYPE_CHECKING, Optional, Self, Sequence
|
from typing import TYPE_CHECKING, Optional, Sequence
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...session import ChannelRef, GroupRef
|
from ...session import ChannelRef, GroupRef
|
||||||
from ...tl import abcs, types
|
from ...tl import abcs, types
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import types
|
from ...tl import types
|
||||||
from .meta import NoPublicConstructor
|
from .meta import NoPublicConstructor
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Optional, Self
|
from typing import Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ....session import ChannelRef
|
from ....session import ChannelRef
|
||||||
from ....tl import abcs, types
|
from ....tl import abcs, types
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import TYPE_CHECKING, Optional, Self, Sequence
|
from typing import TYPE_CHECKING, Optional, Sequence
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ....session import ChannelRef, GroupRef
|
from ....session import ChannelRef, GroupRef
|
||||||
from ....tl import abcs, types
|
from ....tl import abcs, types
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
from typing import Optional, Self
|
from typing import Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ....session import UserRef
|
from ....session import UserRef
|
||||||
from ....tl import abcs, types
|
from ....tl import abcs, types
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from typing import Self
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import NewType, Optional, Self
|
from typing import NewType, Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl.mtproto.types import RpcError as GeneratedRpcError
|
from ...tl.mtproto.types import RpcError as GeneratedRpcError
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,9 @@ from abc import ABC
|
||||||
from asyncio import FIRST_COMPLETED, Event, Future
|
from asyncio import FIRST_COMPLETED, Event, Future
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Generic, Optional, Protocol, Self, Type, TypeVar
|
from typing import Generic, Optional, Protocol, Type, TypeVar
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ..crypto import AuthKey
|
from ..crypto import AuthKey
|
||||||
from ..mtproto import (
|
from ..mtproto import (
|
||||||
|
|
|
@ -4,7 +4,9 @@ import abc
|
||||||
import base64
|
import base64
|
||||||
import re
|
import re
|
||||||
import struct
|
import struct
|
||||||
from typing import Optional, Self, TypeAlias
|
from typing import Optional, TypeAlias
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ...tl import abcs, types
|
from ...tl import abcs, types
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import abc
|
import abc
|
||||||
import struct
|
import struct
|
||||||
from typing import Protocol, Self
|
from typing import Protocol
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from .reader import Reader
|
from .reader import Reader
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ classifiers = [
|
||||||
"Typing :: Typed",
|
"Typing :: Typed",
|
||||||
]
|
]
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
|
dependencies = ["typing-extensions~=4.12.2"]
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
dev = ["pytest~=7.3"]
|
dev = ["pytest~=7.3"]
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,8 @@ def generate(fs: FakeFs, tl: ParsedTl) -> None:
|
||||||
"# pyright: reportUnusedImport=false, reportConstantRedefinition=false"
|
"# pyright: reportUnusedImport=false, reportConstantRedefinition=false"
|
||||||
)
|
)
|
||||||
writer.write("import struct")
|
writer.write("import struct")
|
||||||
writer.write("from typing import Optional, Self, Sequence")
|
writer.write("from typing import Optional, Sequence")
|
||||||
|
writer.write("from typing_extensions import Self")
|
||||||
writer.write("from .. import abcs")
|
writer.write("from .. import abcs")
|
||||||
writer.write("from ..core import Reader, Serializable, serialize_bytes_to")
|
writer.write("from ..core import Reader, Serializable, serialize_bytes_to")
|
||||||
writer.write("_bytes = bytes | bytearray | memoryview")
|
writer.write("_bytes = bytes | bytearray | memoryview")
|
||||||
|
@ -163,7 +164,8 @@ def generate(fs: FakeFs, tl: ParsedTl) -> None:
|
||||||
if function_path not in fs:
|
if function_path not in fs:
|
||||||
writer.write("# pyright: reportUnusedImport=false")
|
writer.write("# pyright: reportUnusedImport=false")
|
||||||
writer.write("import struct")
|
writer.write("import struct")
|
||||||
writer.write("from typing import Optional, Self, Sequence")
|
writer.write("from typing import Optional, Sequence")
|
||||||
|
writer.write("from typing_extensions import Self")
|
||||||
writer.write("from .. import abcs")
|
writer.write("from .. import abcs")
|
||||||
writer.write("from ..core import Request, serialize_bytes_to")
|
writer.write("from ..core import Request, serialize_bytes_to")
|
||||||
writer.write("_bytes = bytes | bytearray | memoryview")
|
writer.write("_bytes = bytes | bytearray | memoryview")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Self
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from ..utils import infer_id
|
from ..utils import infer_id
|
||||||
from .parameter import Parameter, TypeDefNotImplementedError
|
from .parameter import Parameter, TypeDefNotImplementedError
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Self
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Self
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
from .parameter_type import BaseParameter
|
from .parameter_type import BaseParameter
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional, Self
|
from typing import Optional
|
||||||
|
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user