]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Drop Python 3.6 support (#1357)
authorMarcelo Trylesinski <marcelotryle@gmail.com>
Fri, 22 Apr 2022 05:47:28 +0000 (07:47 +0200)
committerGitHub <noreply@github.com>
Fri, 22 Apr 2022 05:47:28 +0000 (07:47 +0200)
* Remove Python 3.6

* Update setup.py

* Add note about Python 3.6 version

* Remove unused import

* Remove PEP 562

* Apply suggestions from code review

Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
.github/workflows/test-suite.yml
README.md
docs/index.md
setup.py
starlette/_pep562.py [deleted file]
starlette/status.py

index 86b4a03d4a7eb5e7a0811421c0ac863cf7575e65..7209fc2bf0aaa89391137b8ebaba3c207e8303f4 100644 (file)
@@ -14,7 +14,7 @@ jobs:
 
     strategy:
       matrix:
-        python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
+        python-version: ["3.7", "3.8", "3.9", "3.10"]
 
     steps:
       - uses: "actions/checkout@v2"
index 2a406d1a686f52bf622e75fb26d5a64128d63d83..404494a35136b02cc8e5d0b33eaf51c3d4a417c7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ It is production-ready, and gives you the following:
 
 ## Requirements
 
-Python 3.6+
+Python 3.7+ (For Python 3.6 support, install version 0.19.1)
 
 ## Installation
 
index 403910d8eb7ff431bb9e7a314b73a27e83dd01a5..1918fc9950a35dcdd1bbb134cb58242eb5350485 100644 (file)
@@ -38,7 +38,7 @@ It is production-ready, and gives you the following:
 
 ## Requirements
 
-Python 3.6+
+Python 3.7+ (For Python 3.6 support, install version 0.19.1)
 
 ## Installation
 
index 479a4a6d4cd51bc6e7f0206e4db804049ed34cc3..e5447f981796f1239b5429497a381ecaa06bfe12 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -25,7 +25,7 @@ def get_long_description():
 
 setup(
     name="starlette",
-    python_requires=">=3.6",
+    python_requires=">=3.7",
     version=get_version("starlette"),
     url="https://github.com/encode/starlette",
     license="BSD",
@@ -40,7 +40,6 @@ setup(
     install_requires=[
         "anyio>=3.4.0,<5",
         "typing_extensions>=3.10.0; python_version < '3.10'",
-        "contextlib2 >= 21.6.0; python_version < '3.7'",
     ],
     extras_require={
         "full": [
@@ -60,7 +59,6 @@ setup(
         "Topic :: Internet :: WWW/HTTP",
         "Framework :: AnyIO",
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
diff --git a/starlette/_pep562.py b/starlette/_pep562.py
deleted file mode 100644 (file)
index a4757ea..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-# flake8: noqa
-"""
-Backport of PEP 562.
-https://pypi.org/search/?q=pep562
-Licensed under MIT
-Copyright (c) 2018 Isaac Muse <isaacmuse@gmail.com>
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
-and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions
-of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-IN THE SOFTWARE.
-"""
-import sys
-from typing import Any, Callable, List, Optional
-
-
-class Pep562:
-    """
-    Backport of PEP 562 <https://pypi.org/search/?q=pep562>.
-    Wraps the module in a class that exposes the mechanics to override `__dir__` and `__getattr__`.
-    The given module will be searched for overrides of `__dir__` and `__getattr__` and use them when needed.
-    """
-
-    def __init__(self, name: str) -> None:  # pragma: no cover
-        """Acquire `__getattr__` and `__dir__`, but only replace module for versions less than Python 3.7."""
-
-        self._module = sys.modules[name]
-        self._get_attr = getattr(self._module, "__getattr__", None)
-        self._get_dir: Optional[Callable[..., List[str]]] = getattr(
-            self._module, "__dir__", None
-        )
-        sys.modules[name] = self  # type: ignore[assignment]
-
-    def __dir__(self) -> List[str]:  # pragma: no cover
-        """Return the overridden `dir` if one was provided, else apply `dir` to the module."""
-
-        return self._get_dir() if self._get_dir else dir(self._module)
-
-    def __getattr__(self, name: str) -> Any:  # pragma: no cover
-        """
-        Attempt to retrieve the attribute from the module, and if missing, use the overridden function if present.
-        """
-
-        try:
-            return getattr(self._module, name)
-        except AttributeError:
-            if self._get_attr:
-                return self._get_attr(name)
-            raise
-
-
-def pep562(module_name: str) -> None:  # pragma: no cover
-    """Helper function to apply PEP 562."""
-
-    if sys.version_info < (3, 7):
-        Pep562(module_name)
index cc52d896c960b144a84a68ce04a0ff10a3799c32..f350d448fec2f38f5bf4493659d751cf791bd1e8 100644 (file)
@@ -9,8 +9,6 @@ import sys
 import warnings
 from typing import List
 
-from starlette._pep562 import pep562
-
 __all__ = (
     "HTTP_100_CONTINUE",
     "HTTP_101_SWITCHING_PROTOCOLS",
@@ -201,6 +199,3 @@ def __getattr__(name: str) -> int:
 
 def __dir__() -> List[str]:
     return sorted(list(__all__) + list(__deprecated__.keys()))  # pragma: no cover
-
-
-pep562(__name__)