This takes advantage of a recent mypy change to respect the return
type of `__new__`. Using that it does the same tedious overloads
as `run` and `check_output`.
This gives better types to `subprocess.check_output` and `subprocess.run`
by laboriously overloading using literals.
To support `run`, I turned `CompletedProcess` into `_CompletedProcess[T]`
with `CompletedProcess = _CompletedProcess[Any]`. I could pretty easily
be convinced that it would be better to just make `CompletedProcess`
generic, though.
I'd like to do the same for Popen but need to make mypy support
believing the type of `__new__` in order for that to work.
Both are None if there were no groups matched. Also 'lastgroup'
will be None if the matched group was nameless.
The Python 2 versions of these annotations already used Optional.
* Add types and functions in types.py that are new in 3.7
* Update `resolve_bases` to accept any iterable of objects, and the same
for `new_class` if the version is at least 3.7
* Add comparison overrides implemented by MethodWrapperType
* Fix mypy error due to over-constrained `__eq__`
Morsel does cast any value to string and therfor any is the correct
typehint. For some keys other types then strings are more
appropiate anyway, max-age can take an integer (unix time) and http-only
a boolean.
Closes#3059
This includes two things to sync up with recent runtime updates:
* Move `Final`, `@final`, `Literal`, and `TypedDict` to `typing` (`typing_extensions` still defines or re-exports them)
* Rename `@typing.runtime` to `@typing.runtime_checkable`, while keeping `@runtime` as a backwards-compatible alias in `typing_extensions`.
According to Ivan, PEP 544 intentionally did not specify whether method conformance check in protocol inference should look at parameter names. For example, it's up to the type checker to decide whether a class with method defined as `def foo(self, x: int)` would implement a protocol with method `def foo(self, y: int)`.
Mypy decided to ignore parameter names altogether, but we Pyre team decided to be more strict and refuse to match different parameter names (as it is unsound to do so when those methods are invoked with named parameters). Since we rely on the typeshed stubs, we want to make sure at least the important stubs on typeshed conform to our standard.
This PR changes `Container.__contains__` to use dunder (i.e. positional-only) parameter name specified in PEP484. This change should not affect mypy since it ignores parameter names, but will make Pyre happy as it eliminate the naming requirement for all classes that want to conform to the `Container` protocol.