Commit Graph

25 Commits

Author SHA1 Message Date
Martin DeMello
d389ef3d85 Remove a few files from the pytype blacklist. (#1628)
Fixes the following issues:

* Literals rather than ... for default values
* None rather than ... for default value of typed variable
* Literals rather than ... # type for top level constants
* # Foo rather than # type: Foo
* return value of init not set to None
2017-09-27 07:57:13 -07:00
Guido van Rossum
76685480e0 Misc fixes found by running mypy against Dropbox internal codebase "C". (#1575) 2017-08-25 20:34:13 -07:00
toejough
f6b013ba52 ignore type for mock.pyi inheritance from Any (#1492)
It is currently required to shut up mypy when run with `--strict`
or `--disallow-subclassing-any`. The `Any` base class is currently
the only way to allow passing an instance of `Mock` to functions
expecting other classes (as is Mock's purpose).
2017-07-19 11:33:59 -07:00
Jelle Zijlstra
ac651d2f8c Fix a few TODOs (#1487)
* fix some easy TODOs

* fix io
2017-07-19 20:27:50 +03:00
Guido van Rossum
350563223f Add Optional[] for all remaining cases of x: <type> = None (#1424)
* Final round of adding Optional[] to type of arguments with default = None
* Update Travis to use --no-implicit-optionals and clarify CONTRIBUTING.md
2017-06-21 10:50:21 -07:00
Carl Meyer
802f3b21b3 Fix __init__ signature for unittest.mock.MagicMock. (#1388) 2017-06-04 10:08:56 -07:00
Benjamin Starling
9abbc0d392 Fix unittest.mock.Mock keyword arguments to address #1282 (#1300) 2017-05-22 23:30:40 -07:00
Jelle Zijlstra
7dd2f80194 Fixes to ContextManager (#1249)
* add typing.ContextManager for 3.6+ only

This fixes the easier part of #655.

Would it make sense to add a generic typing.ContextManager that exists in any Python version?

* update comment

* fix argument types for ContextManager.__exit__

* add AsyncContextManager

* add @asynccontextmanager

* typing.ContextManager now always exists

* back out async-related changes

Will submit those in a separate PR later

* fix import order

* AbstractContextManager only exists in 3.6+

* AbstractContextManager -> ContextManager
2017-05-08 16:21:51 -07:00
Roy Williams
452c1e1d78 Fix patch.object to return a _patch context manager. (#1142)
* Fix patch.object to return a _patch context manager.

This should fix https://github.com/python/typeshed/issues/914

* Prefer None over ... to be consistent with the rest of the file.
2017-04-06 18:47:28 -07:00
Guido van Rossum
1ea3d2de57 Make all single-constraint TypeVars use bound= insteads (plus hack) (#1118)
Another attempt for #804, to unblock python/mypy#2626.
There's a work-around here for python/mypy#1551.
2017-03-29 14:59:24 -07:00
jkleint
433b1b2ebc TestCase.assertSetEqual() should accept frozenset (#1063)
This declares the method to take the union of Set and FrozenSet
rather than AbstractSet since that is where `difference()`
(used by `assertSetEqual()`) is defined.
2017-03-21 23:10:19 -07:00
Jukka Lehtosalo
f296b37e80 Fixes to unittest stubs (#1024)
* Fixes to unittest stubs

* Make types more precise
2017-03-18 14:35:33 -07:00
jkleint
17be26165d Relax type of TestCase.assertCountEqual() params from Sequence to Iterable (#1006)
The stubs for `unittest.TestCase.assertCountEqual()` specify the parameters are Sequences; in fact the method works fine with Iterables, as the first thing the method does is convert them to lists.  [1]  The docs do say sequences, but it appears there is no reason they cannot be Iterables.

[1]: https://github.com/python/cpython/blob/master/Lib/unittest/case.py#L1156
2017-03-15 22:25:20 -07:00
Sebastian Meßmer
85866fe1b9 Fix unittest/mock.pyi (#973)
* Fix unittest/mock.pyi

Add a lot of missing types

* Fix formatting

* Make two and from_kall bool

* Further style fixes

* style fixes
2017-03-08 06:50:28 -08:00
Eric Moyer
62e57618d9 Match assertIsInstance signature with isinstance (#802) 2017-01-09 09:23:46 -08:00
Guido van Rossum
b78eb48b26 Make unittest.removeHandler() an overloaded function.
See https://docs.python.org/3/library/unittest.html#unittest.removeHandler

- Without args it removes the signal handler.
- With a function arg it is a test decorator that temporarily removes
  the handler while the test is running.
2017-01-03 10:15:30 -08:00
Guido van Rossum
94641f5a84 Revert "Make all single-constraint TypeVars to use bounds" (#806)
Reverts python/typeshed#804.

Reason: until python/mypy#1551 is fixed this gives an error whenever @skip() is used.

Specifically see https://github.com/python/typeshed/pull/804#issuecomment-269926655.
2017-01-01 16:35:50 -08:00
Michael Lee
b46366e77d Make all single-constraint TypeVars to use bounds
According to the documentation in the typing module, TypeVars cannot
have only a single constraint. Attempting to do so will actually result
in an exception at runtime. (However, this error is currently ignored
by mypy -- see https://github.com/python/mypy/pull/2626 for a related
pending pull request).

This commit changes all instances of TypeVars using a single constraint
(e.g. `T = TypeVar('T', Foo)`) to use bounds instead (e.g.
`T = TypeVar('T', bound=Foo)`.

This seems to be the correct fix for plistlib after reading the module
docs, but it's less obvious this is correct for unittest. The unittest
module originally had `_FT = TypeVar('_FT', Callable[[Any], Any])` -- an
alternative fix would have been to do `_FT = Callable[[Any], Any]`.

Although I'm not entirely sure what it means to have a bound be a
Callable, I decided to make the assumption that the original authors
probably meant to use TypeVars instead of type aliases for a reason
(possibly to handle classes implementing `__call__`?)
2017-01-01 11:34:19 -08:00
Lukasz Langa
bacd6c0aed Add missing Set imports. 2016-12-21 01:17:55 -08:00
Lukasz Langa
c0c982ada5 Add missing Dict imports. 2016-12-21 01:15:26 -08:00
Lukasz Langa
5b6a9937b2 Fixing flake8 E266 errors 2016-12-20 00:06:36 -08:00
Lukasz Langa
6b5c6626d6 Fixing flake8 E121, E122, E123, E124, E125, E126 errors 2016-12-19 23:53:19 -08:00
Lukasz Langa
fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Reverb Chu
a6ecab3fe7 correct return value type TestRunner.run 2016-12-19 20:28:34 -08:00
Jon Dufresne
2b022d18a4 Add stub for unittest.mock (#731)
Stub generated by stubgen.

Fixes #372
2016-12-07 08:05:01 -08:00