diff --git a/python2/_bisect.py b/2.7/_bisect.py similarity index 100% rename from python2/_bisect.py rename to 2.7/_bisect.py diff --git a/python2/_codecs.py b/2.7/_codecs.py similarity index 100% rename from python2/_codecs.py rename to 2.7/_codecs.py diff --git a/python2/_collections.py b/2.7/_collections.py similarity index 100% rename from python2/_collections.py rename to 2.7/_collections.py diff --git a/python2/_functools.py b/2.7/_functools.py similarity index 100% rename from python2/_functools.py rename to 2.7/_functools.py diff --git a/python2/_heapq.py b/2.7/_heapq.py similarity index 100% rename from python2/_heapq.py rename to 2.7/_heapq.py diff --git a/python2/_hotshot.py b/2.7/_hotshot.py similarity index 100% rename from python2/_hotshot.py rename to 2.7/_hotshot.py diff --git a/python2/_json.py b/2.7/_json.py similarity index 100% rename from python2/_json.py rename to 2.7/_json.py diff --git a/python2/_random.py b/2.7/_random.py similarity index 100% rename from python2/_random.py rename to 2.7/_random.py diff --git a/python2/_sre.py b/2.7/_sre.py similarity index 100% rename from python2/_sre.py rename to 2.7/_sre.py diff --git a/python2/_struct.py b/2.7/_struct.py similarity index 100% rename from python2/_struct.py rename to 2.7/_struct.py diff --git a/python2/array.py b/2.7/array.py similarity index 100% rename from python2/array.py rename to 2.7/array.py diff --git a/python2/cStringIO.py b/2.7/cStringIO.py similarity index 100% rename from python2/cStringIO.py rename to 2.7/cStringIO.py diff --git a/python2/cmath.py b/2.7/cmath.py similarity index 100% rename from python2/cmath.py rename to 2.7/cmath.py diff --git a/python2/datetime.py b/2.7/datetime.py similarity index 100% rename from python2/datetime.py rename to 2.7/datetime.py diff --git a/python2/gc.py b/2.7/gc.py similarity index 100% rename from python2/gc.py rename to 2.7/gc.py diff --git a/python2/math.py b/2.7/math.py similarity index 100% rename from python2/math.py rename to 2.7/math.py diff --git a/python2/operator.py b/2.7/operator.py similarity index 100% rename from python2/operator.py rename to 2.7/operator.py diff --git a/python2/signal.py b/2.7/signal.py similarity index 100% rename from python2/signal.py rename to 2.7/signal.py diff --git a/python2/strop.py b/2.7/strop.py similarity index 100% rename from python2/strop.py rename to 2.7/strop.py diff --git a/python2/thread.py b/2.7/thread.py similarity index 100% rename from python2/thread.py rename to 2.7/thread.py diff --git a/python2/time.py b/2.7/time.py similarity index 100% rename from python2/time.py rename to 2.7/time.py diff --git a/python2/xxsubtype.py b/2.7/xxsubtype.py similarity index 100% rename from python2/xxsubtype.py rename to 2.7/xxsubtype.py diff --git a/python2/zipimport.py b/2.7/zipimport.py similarity index 100% rename from python2/zipimport.py rename to 2.7/zipimport.py diff --git a/python2/zlib.py b/2.7/zlib.py similarity index 100% rename from python2/zlib.py rename to 2.7/zlib.py diff --git a/python3/_bisect.py b/3/_bisect.py similarity index 100% rename from python3/_bisect.py rename to 3/_bisect.py diff --git a/python3/_codecs.py b/3/_codecs.py similarity index 100% rename from python3/_codecs.py rename to 3/_codecs.py diff --git a/python3/_heapq.py b/3/_heapq.py similarity index 100% rename from python3/_heapq.py rename to 3/_heapq.py diff --git a/python3/_json.py b/3/_json.py similarity index 100% rename from python3/_json.py rename to 3/_json.py diff --git a/python3/_operator.py b/3/_operator.py similarity index 100% rename from python3/_operator.py rename to 3/_operator.py diff --git a/python3/_stat.py b/3/_stat.py similarity index 100% rename from python3/_stat.py rename to 3/_stat.py diff --git a/python3/_tracemalloc.py b/3/_tracemalloc.py similarity index 100% rename from python3/_tracemalloc.py rename to 3/_tracemalloc.py diff --git a/python3/_warnings.py b/3/_warnings.py similarity index 100% rename from python3/_warnings.py rename to 3/_warnings.py diff --git a/python3/atexit.py b/3/atexit.py similarity index 100% rename from python3/atexit.py rename to 3/atexit.py diff --git a/python3/cmath.py b/3/cmath.py similarity index 100% rename from python3/cmath.py rename to 3/cmath.py diff --git a/python3/marshal.py b/3/marshal.py similarity index 100% rename from python3/marshal.py rename to 3/marshal.py diff --git a/python3/math.py b/3/math.py similarity index 100% rename from python3/math.py rename to 3/math.py diff --git a/python3/signal.py b/3/signal.py similarity index 100% rename from python3/signal.py rename to 3/signal.py diff --git a/python3/time.py b/3/time.py similarity index 100% rename from python3/time.py rename to 3/time.py diff --git a/README.md b/README.md index 0afb0b724..9e4be1c40 100644 --- a/README.md +++ b/README.md @@ -9,24 +9,39 @@ This data can e.g. be used for static analysis, type checking or type inference. ## Format -Each Python module is represented by a `.py` "stub". This is a normal Python +Each Python module is represented by a `.pyi` "stub". This is a normal Python file (i.e., it can be interpreted by Python 3), except all the methods are empty. Python function annotations ([PEP 3107](https://www.python.org/dev/peps/pep-3107/)) are used to describe the types the function has. See [PEP 484](http://www.python.org/dev/peps/pep-0484/) for the exact syntax of the stub files. +## Directory structure + +We store stubs for both Python 2 as well as Python 3. We also distinguish +between minor versions (E.g. 3.2 <-> 3.3). To accomplish not having to duplicate +modules that are the same between all minor versions, we have e.g. a top-level +directory 3/ that contains all the stubs for Python 3. More specialized stubs +go into e.g. 3.3/ and supersede the more generic stubs in 3/. (And, if needed, +a directory 3.3.1/ would be able to supersede stubs in 3.3/): + +Directory | +------------- | ------------- +2.7/ | Stubs for Python 2.7 +3/ | Stubs for Python 3 +3.3/ | Some specialized stubs for Python 3.3 (replacing generic stubs in 3/) + ## Example The below is an excerpt from the types for the `datetime` module. ``` -MAXYEAR = Undefined(int) -MINYEAR = Undefined(int) -__doc__ = Undefined(str) -__file__ = Undefined(str) -__name__ = Undefined(str) -__package__ = Undefined(None) +MAXYEAR = ... # type: int +MINYEAR = ... # type: int +__doc__ = ... # type: str +__file__ = ... # type: str +__name__ = ... # type: str +__package__ = ... # type: None class date(object): def __init__(self, year: int, month: int, day: int): ... @@ -43,9 +58,5 @@ class date(object): ## Contributions We're welcoming contributions (pull requests) for types of third party -packages. They'll go under python{2,3}/dist-packages/. - -## Roadmap - -This project will move to https://github.com/python/typeshed/ eventually. +packages. They'll go under {2.7,3}/dist-packages/.