Commit Graph

26 Commits

Author SHA1 Message Date
Shantanu
1dd1b701c9 _typeshed: add SupportsLessThan, SupportsLessThanT (#4711)
And use it everywhere. Note there seemed to be a discrepancy between
heapq in Python 2 and 3, so I changed that. It should probably be more
widely used within heapq, but leaving that out of scope for this PR.

Co-authored-by: hauntsaninja <>
2020-10-25 15:04:43 -07:00
Sebastian Rittau
5927e5ca30 Remove most consistency checks and split builtins.pyi into py2/3 files (#4686)
Split builtins.pyi in Python 2 and 3 versions

Partly addresses #4674
2020-10-22 13:39:06 -07:00
Sebastian Rittau
eb1788ac39 Merge Python 2 and 3 builtins.pyi (#2533) 2018-12-21 07:12:41 -08:00
Dave Halter
2cedbc7d63 Add missing attributes of type (#2544)
All these attributes can be seen when using `dir(type)`.

In the future we should be discussing if certain methods on object (like
__eq__) should really be there. IMO this should be defined on type where it
actually also appears when using `dir`.
2018-12-20 20:01:40 -08:00
Jukka Lehtosalo
84548f5bba Revert "fix list concatenation (#2404)" (#2653)
The fix caused regressions for mypy that are difficult to
fix.  See https://github.com/python/mypy/issues/5492 for
context.

This reverts commit 1a42a2c3ea.
2018-11-29 12:20:29 -08:00
anentropic
98e63d2d2f staticmethod and classmethod can wrap any callable (#2650)
Closes: #2645
2018-11-29 14:36:08 +01:00
Dave Halter
84daf7c93b Add __getnewargs__ to float, int, bool, str, bytes, unicode (#2632) 2018-11-26 10:43:12 +01:00
Brandt Bucher
7685462672 Add complete annotations to builtins.compile. (#2606) 2018-11-20 17:48:24 +01:00
Jelle Zijlstra
1a42a2c3ea fix list concatenation (#2404)
Fixes #2383, python/mypy#5492.
2018-11-08 06:42:57 -08:00
Michael J. Sullivan
ffeede30d2 Make SyntaxError.offset be optional (#2557) 2018-10-25 13:54:55 -07:00
Sebastian Rittau
006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Dave Halter
a437fcc886 Add attributes to int and float (#2529)
* real, imag, conjugate all exist on int and float
* numerator, denominator exists on int
2018-10-23 00:44:36 +02:00
Israel Tsadok
2a30462c4a The filter function may return str, tuple or list (#2472)
In Python 2, the return type of filter depends on the iterable
parameter.
2018-09-25 20:26:23 -07:00
Michael J. Sullivan
65863bebf4 make __class__ refer to the current object's class (#2480)
This is just a direct rehash of #1549.
2018-09-25 18:04:37 -07:00
Michael J. Sullivan
4f4a025409 Remove tuple's __init__ method (#2467)
The __new__ method should suffice, and having both interferes with providing
a __new__ in namedtuples, which we want to do to fix
https://github.com/python/mypy/issues/1279.
2018-09-18 20:01:14 -07:00
David Euresti
4e40b035c8 BaseException does not take keyword arguments (#2348)
Fixes #2344
2018-07-27 13:28:43 -07:00
Omar Sandoval
42db5ad4f7 Add missing int.__index__() signature (#2335)
This has been present since Python 2.5.
2018-07-16 15:30:06 -07:00
Steven Karas
d4c15011e4 add __new__ to tuple in python2 (#2304)
this solves #2091 when checking Python 2 code (#2092 only fixed it for Python 3).
2018-07-03 08:18:01 -07:00
Michael Lee
fb92ee84c5 Make overloads in the Python 2 builtins with a 'None' fallback come first (#2261)
In short, this change makes sure calls like `map(None, a, b)` behave as
expected when using `--no-strict-optional` is enabled.

For additional context, see https://github.com/python/mypy/issues/5246
2018-06-20 08:26:06 -07:00
Jelle Zijlstra
0393de4bd7 fix some abstract classes in Python 2 (#2240)
Part of #1476.
2018-06-17 00:56:00 +01:00
Guido van Rossum
c4bf27b835 Copy __builtin__.pyi to builtins.pyi, to fix breakage caused by #2128 (#2215) 2018-06-11 15:10:22 -07:00
Michael Lee
97d9f2eb2c Ensures overloads are ordered from narrow to broad (#2138)
This commit reorders any overloads where the first overload was
"shadowing" the second, preventing it from ever being matched by type
checkers that work by selecting the first matching overload alternative.

For example, the first overload alternative below is strictly broader
then the second, preventing it from ever being selected:

    class Parent: pass
    class Child(Parent): pass

    @overload
    def foo(x: *int) -> Parent: ...
    @overload
    def foo(x: int, y: int) -> Child: ...

The correct thing to do is to either delete the second overload or
rearrange them to look like this:

    @overload
    def foo(x: int, y: int) -> Child: ...
    @overload
    def foo(x: *int) -> Parent: ...

Rationale: I'm currently [working on a proposal][0] that would amend
PEP 484 to (a) mandate type checkers check overloads in order and
(b) prohibit overloads where an earlier alternative completely shadows
a later one.

  [0]: https://github.com/python/typing/issues/253#issuecomment-389262904

This would prohibit overloads that look like the example below, where
the first alternative completely shadows the second.

I figured it would be a good idea to make these changes ahead of time:
if my proposal is accepted, it'd make the transition smoother. If not,
this is hopefully a relatively harmless change.

Note: I think some of these overloads could be simplified (e.g.
`reversed(...)`), but I mostly stuck with rearranging them in case I was
wrong. The only overload I actually changed was `hmac.compare_digest` --
I believe the Python 2 version actually accepts unicode.
2018-05-17 09:45:33 -04:00
Ethan Smith
e9600db2ec Remove symlinks! (#2132) 2018-05-15 15:18:59 -04:00
Łukasz Langa
4603baaa6c Restore stdlib/2/builtins.pyi as a symlink to __builtin__.pyi (#823)
This was broken by python/typeshed@fe0e374.

I confirmed no changes so far were made to builtins.pyi that would require
porting.
2017-01-11 17:24:14 -08:00
Lukasz Langa
fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Guido van Rossum
cb97bb54c0 Move 2.7 to 2 (#635)
Closes #579.
2016-10-26 16:24:49 -07:00