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
This commit is contained in:
Adam Turner 2021-11-11 10:17:23 +00:00 committed by GitHub
parent 7d797bad1f
commit d2981209e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 86 additions and 78 deletions

View File

@ -1,7 +1,5 @@
[flake8]
# fake builtins for python2/*
builtins = basestring, unicode
max-line-length = 90
ignore =
# irrelevant plugins

View File

@ -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

View File

@ -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 <https://bitbucket.org/pypa/wheel/issues/147/bdist_wheel-should-start-by-cleaning-up>`\_)
- `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).

View File

@ -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

View File

@ -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
===========================

View File

@ -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"

View File

@ -1,6 +0,0 @@
[metadata]
version = 4.0.0-pre
license-file = LICENSE
[options]
python_version = >=3.6

View File

@ -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,
)