From b40eb24cdbb06ebd08272f224257fe5a81610e86 Mon Sep 17 00:00:00 2001
From: Gabriel Huber <mail@gabrielhuber.at>
Date: Sat, 16 Nov 2024 00:16:02 +0100
Subject: [PATCH] Fix typing compatibility for Python3.9

---
 a2s/info.py    | 18 +++++++++---------
 a2s/players.py | 10 +++++-----
 a2s/rules.py   | 10 +++++-----
 setup.py       |  2 +-
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/a2s/info.py b/a2s/info.py
index 55087b7..d38c817 100644
--- a/a2s/info.py
+++ b/a2s/info.py
@@ -1,6 +1,6 @@
 import io
 from dataclasses import dataclass
-from typing import Optional, Generic, TypeVar, overload
+from typing import Optional, Generic, Union, TypeVar, overload
 
 from a2s.exceptions import BrokenMessageError, BufferExhaustedError
 from a2s.defaults import DEFAULT_TIMEOUT, DEFAULT_ENCODING
@@ -186,33 +186,33 @@ class GoldSrcInfo(Generic[StrType]):
 
 
 @overload
-def info(address: tuple[str, int], timeout: float, encoding: str) -> SourceInfo[str] | GoldSrcInfo[str]:
+def info(address: tuple[str, int], timeout: float, encoding: str) -> Union[SourceInfo[str], GoldSrcInfo[str]]:
     ...
 
 @overload
-def info(address: tuple[str, int], timeout: float, encoding: None) -> SourceInfo[bytes] | GoldSrcInfo[bytes]:
+def info(address: tuple[str, int], timeout: float, encoding: None) -> Union[SourceInfo[bytes], GoldSrcInfo[bytes]]:
     ...
 
 def info(
     address: tuple[str, int],
     timeout: float = DEFAULT_TIMEOUT,
-    encoding: str | None = DEFAULT_ENCODING
-) -> SourceInfo[str] | SourceInfo[bytes] | GoldSrcInfo[str] | GoldSrcInfo[bytes]:
+    encoding: Union[str, None] = DEFAULT_ENCODING
+) -> Union[SourceInfo[str], SourceInfo[bytes], GoldSrcInfo[str], GoldSrcInfo[bytes]]:
     return request_sync(address, timeout, encoding, InfoProtocol)
 
 @overload
-async def ainfo(address: tuple[str, int], timeout: float, encoding: str) -> SourceInfo[str] | GoldSrcInfo[str]:
+async def ainfo(address: tuple[str, int], timeout: float, encoding: str) -> Union[SourceInfo[str], GoldSrcInfo[str]]:
     ...
 
 @overload
-async def ainfo(address: tuple[str, int], timeout: float, encoding: None) -> SourceInfo[bytes] | GoldSrcInfo[bytes]:
+async def ainfo(address: tuple[str, int], timeout: float, encoding: None) -> Union[SourceInfo[bytes], GoldSrcInfo[bytes]]:
     ...
 
 async def ainfo(
     address: tuple[str, int],
     timeout: float = DEFAULT_TIMEOUT,
-    encoding: str | None = DEFAULT_ENCODING
-) -> SourceInfo[str] | SourceInfo[bytes] | GoldSrcInfo[str] | GoldSrcInfo[bytes]:
+    encoding: Union[str, None] = DEFAULT_ENCODING
+) -> Union[SourceInfo[str], SourceInfo[bytes], GoldSrcInfo[str], GoldSrcInfo[bytes]]:
     return await request_async(address, timeout, encoding, InfoProtocol)
 
 
diff --git a/a2s/players.py b/a2s/players.py
index 1c302e5..46c6ba3 100644
--- a/a2s/players.py
+++ b/a2s/players.py
@@ -1,6 +1,6 @@
 import io
 from dataclasses import dataclass
-from typing import Generic, TypeVar, overload
+from typing import Generic, Union, TypeVar, overload
 
 from a2s.defaults import DEFAULT_TIMEOUT, DEFAULT_ENCODING
 from a2s.a2s_sync import request_sync
@@ -40,8 +40,8 @@ def players(address: tuple[str, int], timeout: float, encoding: None) -> list[Pl
 def players(
     address: tuple[str, int],
     timeout: float = DEFAULT_TIMEOUT,
-    encoding: str | None = DEFAULT_ENCODING
-) -> list[Player[str]] | list[Player[bytes]]:
+    encoding: Union[str, None] = DEFAULT_ENCODING
+) -> Union[list[Player[str]], list[Player[bytes]]]:
     return request_sync(address, timeout, encoding, PlayersProtocol)
 
 @overload
@@ -55,8 +55,8 @@ async def aplayers(address: tuple[str, int], timeout: float, encoding: None) ->
 async def aplayers(
     address: tuple[str, int],
     timeout: float = DEFAULT_TIMEOUT,
-    encoding: str | None = DEFAULT_ENCODING
-) -> list[Player[str]] | list[Player[bytes]]:
+    encoding: Union[str, None] = DEFAULT_ENCODING
+) -> Union[list[Player[str]], list[Player[bytes]]]:
     return await request_async(address, timeout, encoding, PlayersProtocol)
 
 
diff --git a/a2s/rules.py b/a2s/rules.py
index 74a2423..9463384 100644
--- a/a2s/rules.py
+++ b/a2s/rules.py
@@ -1,5 +1,5 @@
 import io
-from typing import overload
+from typing import overload, Union
 
 from a2s.defaults import DEFAULT_TIMEOUT, DEFAULT_ENCODING
 from a2s.a2s_sync import request_sync
@@ -22,8 +22,8 @@ def rules(address: tuple[str, int], timeout: float, encoding: None) -> dict[byte
 def rules(
     address: tuple[str, int],
     timeout: float = DEFAULT_TIMEOUT,
-    encoding: str | None = DEFAULT_ENCODING
-) -> dict[str, str] | dict[bytes, bytes]:
+    encoding: Union[str, None] = DEFAULT_ENCODING
+) -> Union[dict[str, str], dict[bytes, bytes]]:
     return request_sync(address, timeout, encoding, RulesProtocol)
 
 @overload
@@ -37,8 +37,8 @@ async def arules(address: tuple[str, int], timeout: float, encoding: None) -> di
 async def arules(
     address: tuple[str, int],
     timeout: float = DEFAULT_TIMEOUT,
-    encoding: str | None = DEFAULT_ENCODING
-) -> dict[str, str] | dict[bytes, bytes]:
+    encoding: Union[str, None] = DEFAULT_ENCODING
+) -> Union[dict[str, str], dict[bytes, bytes]]:
     return await request_async(address, timeout, encoding, RulesProtocol)
 
 
diff --git a/setup.py b/setup.py
index 516013a..6823e34 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open("README.md", "r") as readme:
 
 setuptools.setup(
     name="python-a2s",
-    version="1.4.0",
+    version="1.4.1",
     author="Gabriel Huber",
     author_email="mail@gabrielhuber.at",
     description="Query Source and GoldSource servers for name, map, players and more.",