* 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
* Add missing methods to Python 2 concurrent.futures
Future.exception_info() and Future.set_exception_info() are methods
present only in the Python 2 backport of concurrent.futures.
* Mark timeout args as optional
The latest mypy complained that the signature didn't match that in the
superclass: Serializer.load_payload() has a serializer argument. I
don't know this project but I think it's best to just add that
argument (rather than adding `# type: ignore`).
* Stubs for boto.kms
* Added types for params
* Added return type and fixed signatures(including review changes)
* Removed make_request from stub(https://github.com/python/mypy/issues/1237). Fixed Dict issue.
* Fixed typo
* Let's be precise about return type
* Added SQLAlchemy annotations
* Made Connection and Engine sublcasses of Connectable (python/typeshed#1018)
* Moved execute() from Connection to Connectable
* Made RowProxy a Mapping and removed Mapping inherited methods
* Made ResultProxy an Iterator of RowProxy
* Added most relevant methods for fetching of ResultProxy
* Added where(), group_by(), order_by() and limit() to Select
* Follow squalchemy module structure
* Created sqlalchemy.engine.result and moved ResultProxy and RowProxy
there
* Created sqlalchemy.engine.interfaces and moved Connectable there
* Added non-deprecated methods to Connectable: connect,
contextual_connect and scalar
* Fixed return type of scalar() to Any
* Missed ResultProxy scalar return
... had it in Connectable only.
This works towards fixing #924. To make the changes easier to review, I'm planning to
fix the issue in two steps:
- This commit makes the 3 stubs compatible with py2
- The next PR will move the 3 stubs to 2and3 and remove the 2 stubs
I wrote this code by diffing the files in third_party/{2,3}/requests and making
appropriate changes to the Python 3 stubs (mostly str/Text stuff). I verified
that the 3 stubs now pass mypy when parsed as 2.7, but I don't have an annotated
requests-using codebase to test on.
CONTRIBUTING.md says to prefer ... Not the most impactful change but fixing
these will allow us to lint for it in the future and get a consistent style.
third_party/2/concurrent/futures is for the Python 2 backport of the
concurrent.futures package from Python 3. In Python 3, all exceptions
are derived from BaseException, but Python 2 also supports exceptions
that are old-style objects (which don't derive from BaseException).
Switch from BaseException to Any to allow old-style exceptions.
All old-style objects are instances of types.InstanceType, so an
alternative to Any is Union[BaseException, types.InstanceType]. This
would help avoid accidentally passing a non-BaseException new-style
object to Future.set_exception(). However, only Executors call that
function (usually), and it's not clear that mypy understands old-style
objects and their relationship to types.InstanceType, so Any is
thought to be the more practical choice.
Mypy now supports metaclasses in Python 2, see python/mypy#2830
so that now __metaclass__ attribute has special treatment.
This PR makes small changes to fix the build (also most PRs are red because of this)
The concurrent.futures.Future class's set_exception() method might be
called with a BaseException that is not an Exception, so change
set_exception()'s parameter type from Exception to BaseException. The
exception set via set_exception() is returned by exception(), so
change exception()'s return type from Exception to BaseException.
I believe this covers both #647 and #719.
Moved sqlalchemy stubs from 2 to 2and3;
changed sqlalchemy/util/compat.pyi:37 to be of type typing.Text;
added incomplete stubs for sqlalchemy.orm.utils and slqalchemy.sql.elements.ColumnElement.
* Update annotations for requests.api.get
Argument params of requests.api.get accepts not only dictionaries of str, str pairs, but dictionaries and tuples of various types.
Also adds the bare minimum of stubs for
cryptography.hazmat.primitives.asymmetric to define the types
referenced here. (cryptography is a full project in its own right,
with lots of types and internal references.)
This tries to use bytes in places where the module documentation
emphasized that this was opaque bytes and str for arguments and
return values that the module seemd to be treating as regular Python
strings, even though this distinction is not horribly meaningful for
Python 2.