Commit Graph

17 Commits

Author SHA1 Message Date
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