Remove typing backport (#882)

Closes: #877
This commit is contained in:
Sebastian Rittau 2021-09-15 17:40:20 +02:00 committed by GitHub
parent 0a9ee8f924
commit 17fe6c4321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 13 additions and 10734 deletions

View File

@ -1,14 +1,5 @@
[tox]
envlist = py27, py34
[testenv]
changedir = src
commands = python -m unittest discover
[testenv:py27]
changedir = python2
[flake8]
# fake builtins for python2/*
builtins = basestring, unicode
max-line-length = 90
@ -23,7 +14,5 @@ ignore =
exclude =
# tests have more relaxed formatting rules
# and its own specific config in .flake8-tests
python2/test_typing.py,
src/test_typing.py,
typing_extensions/src_py2/test_typing_extensions.py,
typing_extensions/src_py3/test_typing_extensions.py,

View File

@ -1,7 +1,7 @@
# This configuration is specific to test_*.py; you need to invoke it
# by specifically naming this config, like this:
#
# $ flake8 --config=.flake8-tests src/test_typing.py python2/test_typing.py
# $ flake8 --config=.flake8-tests [SOURCES]
#
# This will be possibly merged in the future.
@ -28,8 +28,3 @@ ignore =
DW12,
# consistency with mypy
W504
exclude =
# This config is NOT for the main module.
setup.py,
python2/typing.py,
src/typing.py

View File

@ -25,9 +25,6 @@ jobs:
python -m pip install --upgrade pip
pip install -r test-requirements.txt
- name: Test typing
run: pytest python2
- name: Test typing_extensions
run: |
pip install typing
@ -97,4 +94,4 @@ jobs:
run: flake8
- name: Lint tests
run: flake8 --config=.flake8-tests src/test_typing.py python2/test_typing.py typing_extensions/src_py2/test_typing_extensions.py typing_extensions/src_py3/test_typing_extensions.py
run: flake8 --config=.flake8-tests typing_extensions/src_py2/test_typing_extensions.py typing_extensions/src_py3/test_typing_extensions.py

View File

@ -1,16 +1,6 @@
This repository contains backports of the CPython `typing` module to earlier versions of
Python. Therefore, code in this repo should follow CPython's style guidelines and
Code in this repository should follow CPython's style guidelines and
contributors need to sign the PSF Contributor Agreement.
# typing
The `typing` module provided by this repository is a backport for Python versions that
do not have `typing` in the standard library: Python 2.7 and 3.4. These versions are no
longer officially supported by CPython, so there is little remaining interest in keeping
the backport up to date. We will accept contributions backporting new features to
`typing`, but we are no longer actively requiring Python 2 support for all
contributions.
# typing_extensions
The `typing_extensions` module provides a way to access new features from the standard
@ -36,8 +26,7 @@ because async generators were added to the language in 3.6.
# Versioning scheme
`typing_extensions` and `typing` are usually released together using the same version
numbers. The version number indicates the version of the standard library `typing`
The version number of `typing_extensions` indicates the version of the standard library `typing`
module that is reflected in the backport. For example, `typing_extensions` version
3.10.0.0 includes features from the Python 3.10.0 standard library's `typing` module. A
new release that doesn't include any new standard library features would be called
@ -45,25 +34,7 @@ new release that doesn't include any new standard library features would be call
# Workflow for PyPI releases
- Do this for both `typing` and `typing_extensions`
- Run tests under all supported versions. As of April 2021 this includes 2.7, 3.4, 3.5,
3.6, 3.7, 3.8, 3.9.
- On macOS, you can use `pyenv <https://github.com/pyenv/pyenv>`\_ to manage multiple
Python installations. Long story short:
- `xcode-select --install`
- `brew install pyenv`
- `echo 'eval "$(pyenv init -)"' >> ~/.bash_profile`
- Open a new shell
- `pyenv install 3.5.3`
- `pyenv install 3.4.6`
- (assuming you already have 2.7.13 and 3.6.1 from Homebrew)
- `pyenv global system 3.5.3 3.4.6`
- (or some more recent versions)
- You can use `tox` to automate running tests.
- Ensure that GitHub Actions reports no errors.
- Update the version number in `setup.py`.

View File

@ -1,7 +0,0 @@
include LICENSE README.rst
include src/typing.py
include src/test_typing.py
include src/mod_generics_cache.py
include python2/typing.py
include python2/test_typing.py
include python2/mod_generics_cache.py

View File

@ -19,13 +19,7 @@ repository contain some historic discussions.
Repository Content
------------------
This GitHub repo is used for several things:
- A backport of the `typing` module for older Python versions (2.7 and
3.4) is maintained in the [src directory](./src).
Note that the canonical source lives
[upstream](https://github.com/python/cpython/blob/master/Lib/typing.py)
in the CPython repo.
This GitHub repository is used for several things:
- The `typing_extensions` module lives in the
[typing\_extensions](./typing_extensions) directory.
@ -36,11 +30,12 @@ This GitHub repo is used for several things:
- A [discussion forum](https://github.com/python/typing/discussions) for typing-related user
help is hosted here.
Historically, this repository hosted a backport of the
[`typing` module](https://docs.python.org/3/library/typing.html) for older
Python versions. The last released version, supporting Python 2.7 and 3.4,
is [available at PyPI](https://pypi.org/project/typing/).
Workflow
--------
* See [CONTRIBUTING.md](/CONTRIBUTING.md) for more.
* The typing.py module and its unittests are edited in the `src`
subdirectory of this repo. The `python2` subdirectory contains the
Python 2 backport.
See [CONTRIBUTING.md](/CONTRIBUTING.md) for more.

View File

@ -1,14 +0,0 @@
"""Module for testing the behavior of generics across different modules."""
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
pass
class B(Generic[T]):
class A(Generic[T]):
pass

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +0,0 @@
[metadata]
license-file = LICENSE

View File

@ -1,71 +0,0 @@
#!/usr/bin/env python
# coding: utf-8
import sys
from setuptools import setup
if sys.version_info < (2, 7, 0) or (3, 0, 0) <= sys.version_info < (3, 4, 0):
sys.stderr.write('ERROR: You need Python 2.7 or 3.4+ '
'to install the typing package.\n')
exit(1)
version = '3.10.0.0'
description = 'Type Hints for Python'
long_description = '''\
Typing -- Type Hints for Python
This is a backport of the standard library typing module to Python
versions older than 3.5. (See note below for newer versions.)
Typing defines a standard notation for Python function and variable
type annotations. The notation can be used for documenting code in a
concise, standard format, and it has been designed to also be used by
static and runtime type checkers, static analyzers, IDEs and other
tools.
NOTE: in Python 3.5 and later, the typing module lives in the stdlib,
and installing this package has NO EFFECT, because stdlib takes higher
precedence than the installation directory. To get a newer version of
the typing module in Python 3.5 or later, you have to upgrade to a
newer Python (bugfix) version. For example, typing in Python 3.6.0 is
missing the definition of 'Type' -- upgrading to 3.6.2 will fix this.
Also note that most improvements to the typing module in Python 3.7
will not be included in this package, since Python 3.7 has some
built-in support that is not present in older versions (See PEP 560.)
For package maintainers, it is preferred to use
``typing;python_version<"3.5"`` if your package requires it to support
earlier Python versions. This will avoid shadowing the stdlib typing
module when your package is installed via ``pip install -t .`` on
Python 3.5 or later.
'''
package_dir = {2: 'python2', 3: 'src'}[sys.version_info.major]
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Python Software Foundation License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Topic :: Software Development',
]
setup(name='typing',
version=version,
description=description,
long_description=long_description,
author='Guido van Rossum, Jukka Lehtosalo, Łukasz Langa, Ivan Levkivskyi',
author_email='jukka.lehtosalo@iki.fi',
url='https://docs.python.org/3/library/typing.html',
project_urls={'Source': 'https://github.com/python/typing'},
license='PSF',
keywords='typing function annotations type hints hinting checking '
'checker typehints typehinting typechecking backport',
package_dir={'': package_dir},
py_modules=['typing'],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <3.5',
classifiers=classifiers)

View File

@ -1,49 +0,0 @@
"""Module for testing the behavior of generics across different modules."""
import sys
from textwrap import dedent
from typing import TypeVar, Generic, Optional
if sys.version_info[:2] >= (3, 6):
exec(dedent("""
default_a: Optional['A'] = None
default_b: Optional['B'] = None
T = TypeVar('T')
class A(Generic[T]):
some_b: 'B'
class B(Generic[T]):
class A(Generic[T]):
pass
my_inner_a1: 'B.A'
my_inner_a2: A
my_outer_a: 'A' # unless somebody calls get_type_hints with localns=B.__dict__
"""))
else: # This should stay in sync with the syntax above.
__annotations__ = dict(
default_a=Optional['A'],
default_b=Optional['B'],
)
default_a = None
default_b = None
T = TypeVar('T')
class A(Generic[T]):
__annotations__ = dict(
some_b='B'
)
class B(Generic[T]):
class A(Generic[T]):
pass
__annotations__ = dict(
my_inner_a1='B.A',
my_inner_a2=A,
my_outer_a='A' # unless somebody calls get_type_hints with localns=B.__dict__
)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff