From d2981209e30d24fce7fa0c40241d15103c3c69da Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Thu, 11 Nov 2021 10:17:23 +0000 Subject: [PATCH] typing_extensions: Drop Python 2.7, modernize build (#931) * Drop Python 2.7 support -- tests, linting * Adopt pyproject.toml and a build backend (flit) * Add Python 3.7+ types to README.rst --- .flake8 | 2 - .flake8-tests | 2 - CONTRIBUTING.md | 15 +++---- test-requirements.txt | 9 ++--- typing_extensions/README.rst | 10 ++++- typing_extensions/pyproject.toml | 67 ++++++++++++++++++++++++++++++++ typing_extensions/setup.cfg | 6 --- typing_extensions/setup.py | 53 ------------------------- 8 files changed, 86 insertions(+), 78 deletions(-) create mode 100644 typing_extensions/pyproject.toml delete mode 100644 typing_extensions/setup.cfg delete mode 100644 typing_extensions/setup.py diff --git a/.flake8 b/.flake8 index a40ac7fff..be291da98 100644 --- a/.flake8 +++ b/.flake8 @@ -1,7 +1,5 @@ [flake8] -# fake builtins for python2/* -builtins = basestring, unicode max-line-length = 90 ignore = # irrelevant plugins diff --git a/.flake8-tests b/.flake8-tests index dab93cc62..5a97fe897 100644 --- a/.flake8-tests +++ b/.flake8-tests @@ -6,8 +6,6 @@ # This will be possibly merged in the future. [flake8] -# fake builtins for python2/* -builtins = basestring, unicode max-line-length = 100 ignore = # temporary ignores until we sort it out diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 17e6df3b4..895ab8d91 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ standard library, so that users can experiment with them before they are added t standard library. Such features should ideally already be specified in a PEP or draft PEP. -`typing_extensions` supports Python versions 3.6 an up. +`typing_extensions` supports Python versions 3.6 and up. # Versioning scheme @@ -30,17 +30,14 @@ backwards-incompatible changes. - Ensure that GitHub Actions reports no errors. -- Update the version number in `setup.py`. +- Update the version number in `pyproject.toml`. - Build the source and wheel distributions: - - `pip3 install -U setuptools wheel` - - `pip2 install -U setuptools wheel` - - `rm -rf dist/ build/` - - `python3 setup.py sdist bdist_wheel` - - `rm -rf build/` (Works around - `a Wheel bug `\_) - - `python2 setup.py bdist_wheel` + - `pip3 install -U flit` + - `cd typing_extensions` + - `rm -rf dist/` + - `flit build --no-setup-py` - Install the built distributions locally and test (if you were using `tox`, you already tested the source distribution). diff --git a/test-requirements.txt b/test-requirements.txt index 13a0c968f..e29654168 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,4 @@ -flake8; python_version >= '3.6' -flake8-bugbear; python_version >= '3.6' -flake8-pyi; python_version >= '3.6' -pytest==4.6.11; python_version < '3.0' -pytest; python_version >= '3.0' +flake8 +flake8-bugbear +flake8-pyi +pytest diff --git a/typing_extensions/README.rst b/typing_extensions/README.rst index a30c31193..c89fc0425 100644 --- a/typing_extensions/README.rst +++ b/typing_extensions/README.rst @@ -50,7 +50,7 @@ This module currently contains the following: - ``Literal`` - ``NewType`` - ``NoReturn`` -- ``overload`` (note that older versions of ``typing`` only let you use ``overload`` in stubs) +- ``overload`` - ``OrderedDict`` - ``ParamSpec`` - ``ParamSpecArgs`` @@ -64,6 +64,14 @@ This module currently contains the following: - ``TypeGuard`` - ``TYPE_CHECKING`` +Python 3.7+ +----------- + +- ``get_origin`` +- ``get_args`` +- ``get_type_hints`` + + Other Notes and Limitations =========================== diff --git a/typing_extensions/pyproject.toml b/typing_extensions/pyproject.toml new file mode 100644 index 000000000..2ea4171b5 --- /dev/null +++ b/typing_extensions/pyproject.toml @@ -0,0 +1,67 @@ +# Build system requirements. +[build-system] +requires = ["flit_core >=3.4,<4"] +build-backend = "flit_core.buildapi" + +# Project metadata +[project] +name = "typing_extensions" +version = "4.0.0-pre" +description = "Backported and Experimental Type Hints for Python 3.6+" +readme.text = """\ +Typing Extensions -- Backported and Experimental Type Hints for Python + +The ``typing`` module was added to the standard library in Python 3.5, but +many new features have been added to the module since then. +This means users of older Python versions who are unable to upgrade will not be +able to take advantage of new types added to the ``typing`` module, such as +``typing.Protocol`` or ``typing.TypedDict``. + +The ``typing_extensions`` module contains backports of these changes. +Experimental types that may eventually be added to the ``typing`` +module are also included in ``typing_extensions``. +""" +readme.content-type = "text/x-rst" +requires-python = ">=3.6" +urls.Home = "https://github.com/python/typing/blob/master/typing_extensions/README.rst" +license.file = "LICENSE" +keywords = [ + "annotations", + "backport", + "checker", + "checking", + "function", + "hinting", + "hints", + "type", + "typechecking", + "typehinting", + "typehints", + "typing" +] +# Classifiers list: https://pypi.org/classifiers/ +classifiers = [ + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: Python Software Foundation License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "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", + "Topic :: Software Development" +] + +# Project metadata -- authors. Flit stores this as a list of dicts, so it can't +# be inline above. +[[project.authors]] +name = "Guido van Rossum, Jukka Lehtosalo, Łukasz Langa, Michael Lee" +email = "levkivskyi@gmail.com" + +# This tells Flit that the module is stored in the src_py3 directory. +[tool.flit.module] +name = "src_py3/typing_extensions" diff --git a/typing_extensions/setup.cfg b/typing_extensions/setup.cfg deleted file mode 100644 index 1d80ff91f..000000000 --- a/typing_extensions/setup.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[metadata] -version = 4.0.0-pre -license-file = LICENSE - -[options] -python_version = >=3.6 diff --git a/typing_extensions/setup.py b/typing_extensions/setup.py deleted file mode 100644 index dde798433..000000000 --- a/typing_extensions/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -import sys -from setuptools import setup - -if sys.version_info < (3, 6, 0): - sys.stderr.write('ERROR: You need Python 3.6+ ' - 'to install typing_extensions.\n') - exit(1) - -description = 'Backported and Experimental Type Hints for Python 3.6+' -long_description = '''\ -Typing Extensions -- Backported and Experimental Type Hints for Python - -The ``typing`` module was added to the standard library in Python 3.5, but -many new features have been added to the module since then. -This means users of older Python versions who are unable to upgrade will not be -able to take advantage of new types added to the ``typing`` module, such as -``typing.Protocol`` or ``typing.TypedDict``. - -The ``typing_extensions`` module contains backports of these changes. -Experimental types that will eventually be added to the ``typing`` -module are also included in ``typing_extensions``. -''' - -classifiers = [ - 'Development Status :: 3 - Alpha', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Python Software Foundation License', - 'Operating System :: OS Independent', - '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', - 'Topic :: Software Development', -] - -setup(name='typing_extensions', - description=description, - long_description=long_description, - author='Guido van Rossum, Jukka Lehtosalo, Łukasz Langa, Michael Lee', - author_email='levkivskyi@gmail.com', - url='https://github.com/python/typing/blob/master/typing_extensions/README.rst', - license='PSF', - keywords='typing function annotations type hints hinting checking ' - 'checker typehints typehinting typechecking backport', - package_dir={'': 'src_py3'}, - py_modules=['typing_extensions'], - classifiers=classifiers, - )