Skip to content

Commit fcc7df6

Browse files
add CONTRIBUTING.md (#806)
1 parent edd78b2 commit fcc7df6

File tree

2 files changed

+86
-37
lines changed

2 files changed

+86
-37
lines changed

CONTRIBUTING.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
This repository contains backports of the CPython `typing` module to earlier versions of
2+
Python. Therefore, code in this repo should follow CPython's style guidelines and
3+
contributors need to sign the PSF Contributor Agreement.
4+
5+
# typing
6+
7+
The `typing` module provided by this repository is a backport for Python versions that
8+
do not have `typing` in the standard library: Python 2.7 and 3.4. These versions are no
9+
longer officially supported by CPython, so there is little remaining interest in keeping
10+
the backport up to date. We will accept contributions backporting new features to
11+
`typing`, but we are no longer actively requiring Python 2 support for all
12+
contributions.
13+
14+
# typing_extensions
15+
16+
The `typing_extensions` module provides a way to access new features from the standard
17+
library `typing` module in older versions of Python. For example, Python 3.10 adds
18+
`typing.TypeGuard`, but users of older versions of Python can use `typing_extensions` to
19+
use `TypeGuard` in their code even if they are unable to upgrade to Python 3.10.
20+
21+
If you contribute the runtime implementation of a new `typing` feature to CPython, you
22+
are encouraged to also implement the feature in `typing_extensions`. Because the runtime
23+
implementation of much of the infrastructure in the `typing` module has changed over
24+
time, this may require different code for some older Python versions.
25+
26+
`typing_extensions` may also include experimental features that are not yet part of the
27+
standard library, so that users can experiment with them before they are added to the
28+
standard library. Such features should ideally already be specified in a PEP or draft
29+
PEP.
30+
31+
`typing_extensions` still supports all Python versions supported by `typing`, down to
32+
Python 2.7 and 3.4. However, it is OK to omit support for Python versions that have
33+
reached end of life if doing so is too difficult or otherwise does not make sense. For
34+
example, `typing_extensions.AsyncGenerator` only exists on Python 3.6 and higher,
35+
because async generators were added to the language in 3.6.
36+
37+
# Versioning scheme
38+
39+
`typing_extensions` and `typing` are usually released together using the same version
40+
numbers. The version number indicates the version of the standard library `typing`
41+
module that is reflected in the backport. For example, `typing_extensions` version
42+
3.10.0.0 includes features from the Python 3.10.0 standard library's `typing` module. A
43+
new release that doesn't include any new standard library features would be called
44+
3.10.0.1.
45+
46+
# Workflow for PyPI releases
47+
48+
- Do this for both `typing` and `typing_extensions`
49+
50+
- Run tests under all supported versions. As of April 2021 this includes 2.7, 3.4, 3.5,
51+
3.6, 3.7, 3.8, 3.9.
52+
53+
- On macOS, you can use `pyenv <https://github.com/pyenv/pyenv>`\_ to manage multiple
54+
Python installations. Long story short:
55+
56+
- `xcode-select --install`
57+
- `brew install pyenv`
58+
- `echo 'eval "$(pyenv init -)"' >> ~/.bash_profile`
59+
- Open a new shell
60+
- `pyenv install 3.5.3`
61+
- `pyenv install 3.4.6`
62+
- (assuming you already have 2.7.13 and 3.6.1 from Homebrew)
63+
- `pyenv global system 3.5.3 3.4.6`
64+
- (or some more recent versions)
65+
66+
- You can use `tox` to automate running tests.
67+
68+
- Update the version number in `setup.py`.
69+
70+
- Build the source and wheel distributions:
71+
72+
- `pip3 install -U setuptools wheel`
73+
- `pip2 install -U setuptools wheel`
74+
- `rm -rf dist/ build/`
75+
- `python3 setup.py sdist bdist_wheel`
76+
- `rm -rf build/` (Works around
77+
`a Wheel bug <https://bitbucket.org/pypa/wheel/issues/147/bdist_wheel-should-start-by-cleaning-up>`\_)
78+
- `python2 setup.py bdist_wheel`
79+
80+
- Install the built distributions locally and test (if you were using `tox`, you already
81+
tested the source distribution).
82+
83+
- Make sure twine is up to date, then run `twine upload dist/*`.

README.md

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This GitHub repo is used for three separate things:
1010
[typing-sig](https://mail.python.org/mailman3/lists/typing-sig.python.org/)
1111
is more appropriate these days.
1212

13-
- A copy of the `typing` module for older Python versions (2.7 and
13+
- A backport of the `typing` module for older Python versions (2.7 and
1414
3.4) is maintained here. Note that the canonical source lives
1515
[upstream](https://github.com/python/cpython/blob/master/Lib/typing.py)
1616
in the CPython repo.
@@ -20,42 +20,8 @@ This GitHub repo is used for three separate things:
2020
Workflow
2121
--------
2222

23+
* See [CONTRIBUTING.md](/CONTRIBUTING.md) for more.
24+
2325
* The typing.py module and its unittests are edited in the `src`
2426
subdirectory of this repo. The `python2` subdirectory contains the
2527
Python 2 backport.
26-
27-
Workflow for PyPI releases
28-
--------------------------
29-
30-
* Run tests under all supported versions. As of April 2021 this includes
31-
2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9.
32-
33-
* On macOS, you can use `pyenv <https://github.com/pyenv/pyenv>`_ to
34-
manage multiple Python installations. Long story short:
35-
36-
* ``xcode-select --install``
37-
* ``brew install pyenv``
38-
* ``echo 'eval "$(pyenv init -)"' >> ~/.bash_profile``
39-
* Open a new shell
40-
* ``pyenv install 3.5.3``
41-
* ``pyenv install 3.4.6``
42-
* (assuming you already have 2.7.13 and 3.6.1 from Homebrew)
43-
* ``pyenv global system 3.5.3 3.4.6``
44-
45-
* You can use ``tox`` to automate running tests.
46-
47-
* Update the version number in ``setup.py``.
48-
49-
* Build the source and wheel distributions:
50-
51-
* ``pip3 install -U setuptools wheel``
52-
* ``pip2 install -U setuptools wheel``
53-
* ``rm -rf dist/ build/``
54-
* ``python3 setup.py sdist bdist_wheel``
55-
* ``rm -rf build/`` (Works around `a Wheel bug <https://bitbucket.org/pypa/wheel/issues/147/bdist_wheel-should-start-by-cleaning-up>`_)
56-
* ``python2 setup.py bdist_wheel``
57-
58-
* Install the built distributions locally and test (if you
59-
were using ``tox``, you already tested the source distribution).
60-
61-
* Make sure twine is up to date, then run ``twine upload dist/*``.

0 commit comments

Comments
 (0)