This commit adds some incomplete stubs for the fractions module. In
particular, this commit does not add type signatures for the more
complex functions (such as `__add__`), and just leaves their types as
effectively `Any`.
* Refine stubs for Python 2's decimal module
The decimal module for Python 2 was relatively incomplete, unlike the
decimal module for Python 3. This commit copies the relevant type
signatures from Python 3's decimal module to Python 2's.
There was a lot of code in both stubs and it wasn't clear to me if it
was safe to merge the two modules together, so I refrained from doing
so.
* Allow comparisions with Decimals and Floats
This commit loosens the types for Decimals to allow comparisons like
`Decimal('3.14') < 4.2`. Previously, you could compare decimals with
only other decimals or ints.
* Partially refine numbers.pyi
This commit refines numbers.pyi. More specifically, it...
- Adds in explicit type annotations where it's obvious how to do
so (leaving more non-obvious type signatures alone).
- Adds in missing '@abstractmethod' decorators
- Combines together the Python 2 and Python 3 versions of numbers.pyi.
* Merges Python 2 and Python 3 numbers.pyi
This commit removes the old `stdlib/2.7/numbers.pyi` file and moves the
previously-committed `stdlib/3/numbers.pyi` to the shared `2and3`
directory.
* Modify comment at top of numbers.pyi
Since the stubs are no longer identical to what stubgen creates, the
comment should also probably be changed.
This is necessary, because exception formatting functions like `traceback.format_exception()` expect to get `Type[BaseException]`, but sys.excepthook only provided `type`
* Make Mapping covariant.
Fixes#510.
This requires a `# type: ignore` on `__getitem__` and `get` because
mypy complains about covariant parameters.
FWIW typing.py needs to be changed too. (It was covariant in the
value but invariant in the key -- typeshed was invariant in both.)
* Delete outdated comment.
* Backpeddle a bit -- Mapping key type should not be covariant.
In Python, it's possible to use the `next` builtin method on file
objects produced by `open`. This change modifies `typing.IO` so this
usage will successfully typecheck.
* Stub: asyncore.pyi
I can't really test this stub since I don't use this module. I believe it's not far from the real thing.
It's based on the source code and not on the documentation.
https://hg.python.org/cpython/file/default/Lib/asyncore.py
* Option ->Optional
* add hint to count, remove addr
* make read/write explicit functions
* add synchat.pyi, move to 2and3
* change sys.version_info test
* try reversing the syntax
I went through each method in the source and verified the inputs it accepts and outputs it gives. I also redefined a few methods on the `Path` class so that MyPy knows they return `Path` instead of `PurePath`. This is really just a temporary workaround until https://github.com/python/mypy/issues/1212 is fixed, but greatly improves the process of working with the `pathlib` module and is therefore likely worth the duplication.