Commit Graph

18 Commits

Author SHA1 Message Date
Eric Traut
04c74640f0 Removed imported symbols that are not accessed or re-exported (#4387)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-08-05 22:49:17 -07:00
Jelle Zijlstra
0142a87da8 adjust isort config (#4290)
Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07:00
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Vlad Emelianov
d21370965a Allow Warning message in showwarning and formatwarning (#4239) 2020-06-17 17:44:09 -07:00
Jelle Zijlstra
e9a9103afc bring back attribute types in warnings.WarningMessage (#3810)
Signed-off-by: Oleg Höfling <oleg.hoefling@gmail.com>
2020-03-05 17:15:13 -08:00
dave-shawley
c44a556fb0 Add typestubs for the warnings module (#3543) 2019-12-21 12:29:34 -08:00
Jelle Zijlstra
d215f502c6 Improve warnings stubs (#3501)
* merge 2and3 for _warnings

* move warn and warn_explicit into _warnings
2019-12-03 14:33:37 +01:00
Michał Słapek
41bf6a1982 Refactor warnings.catch_warning to be a class. (#3499) 2019-11-25 19:35:27 -08:00
Michał Słapek
34d68ab0a2 Add warnings.catch_warning type hints with Literal. (#3464)
Closes: #3463
2019-11-14 11:08:50 +01:00
Sebastian Rittau
ec7960a8cb Convert namedtuples to class syntax (#3321) 2019-10-20 10:37:33 +02:00
Michael Lee
b294782183 Make most contextmanager __exit__ signatures return Optional[bool] (#3179)
This pull request is a follow-up to https://github.com/python/mypy/issues/7214.

In short, within that mypy issue, we found it would be helpful to
determine between contextmanagers that can "swallow" exceptions vs ones
that can't. This helps prevent some false positive when using flags that
analyze control flow such as `--warn-unreachable`. To do this,
Jelle proposed assuming that only contextmanagers where the `__exit__`
returns `bool` are assumed to swallow exceptions.

This unfortunately required the following typeshed changes:

1. The typing.IO, threading.Lock, and concurrent.futures.Executor
   were all modified so `__exit__` returns `Optional[None]` instead
   of None -- along with all of their subclasses.

   I believe these three types are meant to be subclassed, so I felt
   picking the more general type was correct.

2. There were also a few concrete types (e.g. see socketserver,
   subprocess, ftplib...) that I modified to return `None` -- I checked
   the source code, and these all seem to return None (and don't appear
   to be meant to be subclassable).

3. contextlib.suppress was changed to return bool. I also double-checked
   the unittest modules and modified a subset of those contextmanagers,
   leaving ones like `_AssertRaisesContext` alone.
2019-08-16 16:13:33 -07:00
Ran Benita
9a7b286c66 warnings: ignore the type of category when message is a Warning (#3121) 2019-07-24 21:46:23 +02:00
Sergey Machulskis
bec2fef7fa threading.Lock issue when using it with ExitStack (#2908)
* Make threading primitives ContextManagers
* Make catch_warnings ContextManager
* Make SMTP ContextManager
* Fix type of exc_type for SMTP
2019-04-11 21:39:17 +02: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
hashstat
15f737d2a8 Corrects return type of warnings.formatwarning(). (#1640) 2017-10-04 08:37:08 -07:00
Lukasz Langa
5f416fae64 Add missing List imports. 2016-12-21 01:06:52 -08:00
Valérian Rousset
3eedf73a3a Add types to stub for warnings module. (#342) 2016-07-06 09:58:49 -07:00
Matthias Kramm
5f76369093 Move warnings.pyi into 2and3/. 2016-04-08 14:43:43 -07:00