From 8967bc35456549baeb32acf103bc43214553edf7 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 11 Dec 2021 15:05:07 +0100 Subject: [PATCH 1/6] Remove Python 3.6 --- .github/workflows/test-suite.yml | 2 +- README.md | 2 +- docs/index.md | 2 +- setup.py | 6 ++---- starlette/concurrency.py | 7 +------ 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 86b4a03d4..7209fc2bf 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -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" diff --git a/README.md b/README.md index a7d94904d..e0b09226d 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ It is production-ready, and gives you the following: ## Requirements -Python 3.6+ +Python 3.7+ ## Installation diff --git a/docs/index.md b/docs/index.md index a9ec4106f..872f201a5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -36,7 +36,7 @@ It is production-ready, and gives you the following: ## Requirements -Python 3.6+ +Python 3.7+ ## Installation diff --git a/setup.py b/setup.py index 3b8d32e16..063793d6a 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import os import re -from setuptools import setup, find_packages +from setuptools import find_packages, setup def get_version(package): @@ -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 @@ def get_long_description(): install_requires=[ "anyio>=3.0.0,<4", "typing_extensions; python_version < '3.8'", - "contextlib2 >= 21.6.0; python_version < '3.7'", ], extras_require={ "full": [ @@ -59,7 +58,6 @@ def get_long_description(): "Operating System :: OS Independent", "Topic :: Internet :: WWW/HTTP", "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/concurrency.py b/starlette/concurrency.py index e89d1e047..94fb8fc24 100644 --- a/starlette/concurrency.py +++ b/starlette/concurrency.py @@ -1,15 +1,10 @@ +import contextvars import functools import typing from typing import Any, AsyncGenerator, Iterator import anyio -try: - import contextvars # Python 3.7+ only or via contextvars backport. -except ImportError: # pragma: no cover - contextvars = None # type: ignore - - T = typing.TypeVar("T") From 7a60d44a0de4d1929fa904c8c46a768f148e2013 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 11 Dec 2021 15:12:08 +0100 Subject: [PATCH 2/6] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 063793d6a..23e0a88bd 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import os import re -from setuptools import find_packages, setup +from setuptools import setup, find_packages def get_version(package): From 08b2b95dba1a5cd6700eaeb33c04d685865b8fbb Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 8 Jan 2022 12:32:13 +0100 Subject: [PATCH 3/6] Add note about Python 3.6 version --- README.md | 2 +- docs/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e0b09226d..5fcb61f84 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ It is production-ready, and gives you the following: ## Requirements -Python 3.7+ +Python 3.7+ (For Python 3.6 support, install version 0.17.1) ## Installation diff --git a/docs/index.md b/docs/index.md index 872f201a5..a0662b8e1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -36,7 +36,7 @@ It is production-ready, and gives you the following: ## Requirements -Python 3.7+ +Python 3.7+ (For Python 3.6 support, install version 0.17.1) ## Installation From 09e2d91f9b849e28cba9f36f49130419a7c3c3b7 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 2 Apr 2022 14:22:00 +0200 Subject: [PATCH 4/6] Remove unused import --- starlette/concurrency.py | 1 - 1 file changed, 1 deletion(-) diff --git a/starlette/concurrency.py b/starlette/concurrency.py index 6c7e5a5cf..5c76cb3df 100644 --- a/starlette/concurrency.py +++ b/starlette/concurrency.py @@ -1,4 +1,3 @@ -import contextvars import functools import sys import typing From fbf0a8f82d66daa61c7a929a4fbaa39e7639994a Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Fri, 22 Apr 2022 07:08:58 +0200 Subject: [PATCH 5/6] Remove PEP 562 --- starlette/_pep562.py | 62 -------------------------------------------- starlette/status.py | 5 ---- 2 files changed, 67 deletions(-) delete mode 100644 starlette/_pep562.py diff --git a/starlette/_pep562.py b/starlette/_pep562.py deleted file mode 100644 index a4757eac4..000000000 --- a/starlette/_pep562.py +++ /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 -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 . - 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) diff --git a/starlette/status.py b/starlette/status.py index cc52d896c..f350d448f 100644 --- a/starlette/status.py +++ b/starlette/status.py @@ -9,8 +9,6 @@ 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__) From 66c8dfd343c7f794371c33d383ca12d1aac0b7fa Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Fri, 22 Apr 2022 07:36:48 +0200 Subject: [PATCH 6/6] Apply suggestions from code review --- README.md | 2 +- docs/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7ea5c6c44..404494a35 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ It is production-ready, and gives you the following: ## Requirements -Python 3.7+ (For Python 3.6 support, install version 0.17.1) +Python 3.7+ (For Python 3.6 support, install version 0.19.1) ## Installation diff --git a/docs/index.md b/docs/index.md index e2b1b7559..1918fc995 100644 --- a/docs/index.md +++ b/docs/index.md @@ -38,7 +38,7 @@ It is production-ready, and gives you the following: ## Requirements -Python 3.7+ (For Python 3.6 support, install version 0.17.1) +Python 3.7+ (For Python 3.6 support, install version 0.19.1) ## Installation