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 2a406d1a6..404494a35 100644 --- 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 diff --git a/docs/index.md b/docs/index.md index 403910d8e..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.6+ +Python 3.7+ (For Python 3.6 support, install version 0.19.1) ## Installation diff --git a/setup.py b/setup.py index 479a4a6d4..e5447f981 100644 --- 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 @@ def get_long_description(): 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 @@ def get_long_description(): "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 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__)