From 2074009a8d5b4b3477c508277694c6ec3fd48eb0 Mon Sep 17 00:00:00 2001 From: Kevin Tindall Date: Wed, 26 Jan 2022 10:59:35 -0600 Subject: [PATCH] Use typing_extensions for SupportsIndex Co-authored-by: ItsDrike --- mcstatus/protocol/connection.py | 11 +++-------- poetry.lock | 4 ++-- pyproject.toml | 1 + 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/mcstatus/protocol/connection.py b/mcstatus/protocol/connection.py index e49e0e9..891b0bc 100644 --- a/mcstatus/protocol/connection.py +++ b/mcstatus/protocol/connection.py @@ -1,13 +1,8 @@ from abc import abstractmethod, ABC +from typing import SupportsBytes, Iterable, Tuple, Union +from typing_extensions import SupportsIndex # Python 3.7 doesn't support this yet. -try: - from typing import SupportsBytes, Iterable, SupportsIndex, Tuple, Union - - BytesConvertable = Union[SupportsIndex, Iterable[SupportsIndex]] -except ImportError: - from typing import SupportsBytes, Iterable, Tuple, Union - - BytesConvertable = Union[int, Iterable[int]] +BytesConvertable = Union[SupportsIndex, Iterable[SupportsIndex]] import socket import struct import asyncio diff --git a/poetry.lock b/poetry.lock index 32add1b..abf7c08 100644 --- a/poetry.lock +++ b/poetry.lock @@ -715,7 +715,7 @@ python-versions = ">=3.6" name = "typing-extensions" version = "4.0.1" description = "Backported and Experimental Type Hints for Python 3.6+" -category = "dev" +category = "main" optional = false python-versions = ">=3.6" @@ -786,7 +786,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" python-versions = ">=3.7" -content-hash = "9e819727883898bb2d4f2bd80e98f1488c66584232802e51325d534e15639edd" +content-hash = "929f5970e749a6090ecd06bf16d1c2e52f6f5dad348d4472c1d5d92b6c9235c3" [metadata.files] asyncio-dgram = [ diff --git a/pyproject.toml b/pyproject.toml index 8060c3b..c2b1e62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ python = ">=3.7" asyncio-dgram = "1.2.0" click = "7.1.2" dnspython = "2.1.0" +typing-extensions = "^4.0.1" [tool.poetry.dev-dependencies] coverage = "^6.1.1"