From 7ea30961aeca35559b7d7244814f9e2d8a99dcb1 Mon Sep 17 00:00:00 2001
From: Lonami Exo <totufals@hotmail.com>
Date: Sun, 9 Jan 2022 13:00:45 +0100
Subject: [PATCH] Bump minimum required Python version to 3.7

---
 .github/workflows/python.yml            |  2 +-
 pyproject.toml                          |  2 +-
 readthedocs/basic/signing-in.rst        | 19 +++++--------------
 readthedocs/developing/testing.rst      |  2 +-
 readthedocs/misc/v2-migration-guide.rst |  4 +++-
 setup.py                                |  6 +++---
 telethon/_misc/hints.py                 | 18 +++++-------------
 7 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml
index d3c34a20..f3fd3106 100644
--- a/.github/workflows/python.yml
+++ b/.github/workflows/python.yml
@@ -8,7 +8,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python-version: ["3.5", "3.6", "3.7", "3.8"]
+        python-version: ["3.7", "3.8", "3.9", "3.10"]
     steps:
     - uses: actions/checkout@v1
     - name: Set up Python ${{ matrix.python-version }}
diff --git a/pyproject.toml b/pyproject.toml
index daae10fa..ca877203 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
 [tool.tox]
 legacy_tox_ini = """
 [tox]
-envlist = py35,py36,py37,py38
+envlist = py37,py38
 
 # run with tox -e py
 [testenv]
diff --git a/readthedocs/basic/signing-in.rst b/readthedocs/basic/signing-in.rst
index 7f584a95..c7b60507 100644
--- a/readthedocs/basic/signing-in.rst
+++ b/readthedocs/basic/signing-in.rst
@@ -122,11 +122,9 @@ with `@BotFather <https://t.me/BotFather>`_.
 Signing In behind a Proxy
 =========================
 
-If you need to use a proxy to access Telegram,
-you will need to either:
+If you need to use a proxy to access Telegram, you will need to:
 
-* For Python >= 3.6 : `install python-socks[asyncio]`__
-* For Python <= 3.5 : `install PySocks`__
+`install python-socks[asyncio]`__
 
 and then change
 
@@ -147,16 +145,9 @@ consisting of parameters described `in PySocks usage`__.
 
 The allowed values for the argument ``proxy_type`` are:
 
-* For Python <= 3.5:
-    * ``socks.SOCKS5`` or ``'socks5'``
-    * ``socks.SOCKS4`` or ``'socks4'``
-    * ``socks.HTTP`` or ``'http'``
-
-* For Python >= 3.6:
-    * All of the above
-    * ``python_socks.ProxyType.SOCKS5``
-    * ``python_socks.ProxyType.SOCKS4``
-    * ``python_socks.ProxyType.HTTP``
+* ``python_socks.ProxyType.SOCKS5``
+* ``python_socks.ProxyType.SOCKS4``
+* ``python_socks.ProxyType.HTTP``
 
 
 Example:
diff --git a/readthedocs/developing/testing.rst b/readthedocs/developing/testing.rst
index badb7dc6..dfabe73f 100644
--- a/readthedocs/developing/testing.rst
+++ b/readthedocs/developing/testing.rst
@@ -71,7 +71,7 @@ version incompatabilities.
 
 Tox environments are declared in the ``tox.ini`` file. The default
 environments, declared at the top, can be simply run with ``tox``. The option
-``tox -e py36,flake`` can be used to request specific environments to be run.
+``tox -e py37,flake`` can be used to request specific environments to be run.
 
 Brief Introduction to Pytest-cov
 ================================
diff --git a/readthedocs/misc/v2-migration-guide.rst b/readthedocs/misc/v2-migration-guide.rst
index 42285c1d..d9e3c270 100644
--- a/readthedocs/misc/v2-migration-guide.rst
+++ b/readthedocs/misc/v2-migration-guide.rst
@@ -16,7 +16,9 @@ good chance you were not relying on this to begin with".
 Python 3.5 is no longer supported
 ---------------------------------
 
-The library will no longer attempt to support Python 3.5. The minimum version is now Python 3.6.
+The library will no longer attempt to support Python 3.5. The minimum version is now Python 3.7.
+
+This also means workarounds for 3.6 and below have been dropped.
 
 
 User, chat and channel identifiers are now 64-bit numbers
diff --git a/setup.py b/setup.py
index 05f0f7b6..caf4a54a 100755
--- a/setup.py
+++ b/setup.py
@@ -208,7 +208,7 @@ def main(argv):
             # See https://stackoverflow.com/a/40300957/4759433
             # -> https://www.python.org/dev/peps/pep-0345/#requires-python
             # -> http://setuptools.readthedocs.io/en/latest/setuptools.html
-            python_requires='>=3.5',
+            python_requires='>=3.7',
 
             # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
             classifiers=[
@@ -223,10 +223,10 @@ def main(argv):
                 'License :: OSI Approved :: MIT License',
 
                 'Programming Language :: Python :: 3',
-                'Programming Language :: Python :: 3.5',
-                'Programming Language :: Python :: 3.6',
                 'Programming Language :: Python :: 3.7',
                 'Programming Language :: Python :: 3.8',
+                'Programming Language :: Python :: 3.9',
+                'Programming Language :: Python :: 3.10',
             ],
             keywords='telegram api chat client library messaging mtproto',
             packages=find_packages(exclude=[
diff --git a/telethon/_misc/hints.py b/telethon/_misc/hints.py
index 47f26a8f..52951cec 100644
--- a/telethon/_misc/hints.py
+++ b/telethon/_misc/hints.py
@@ -48,19 +48,11 @@ FileLike = typing.Union[
     _tl.TypeInputFileLocation
 ]
 
-# Can't use `typing.Type` in Python 3.5.2
-# See https://github.com/python/typing/issues/266
-try:
-    OutFileLike = typing.Union[
-        str,
-        typing.Type[bytes],
-        typing.BinaryIO
-    ]
-except TypeError:
-    OutFileLike = typing.Union[
-        str,
-        typing.BinaryIO
-    ]
+OutFileLike = typing.Union[
+    str,
+    typing.Type[bytes],
+    typing.BinaryIO
+]
 
 MessageLike = typing.Union[str, _tl.Message]
 MessageIDLike = typing.Union[int, _tl.Message, _tl.TypeInputMessage]