This makes mypy think that conditions like
parameter.kind is Parameter.POSITIONAL_OR_KEYWORD
are always false, which triggers `unreachable` warnings, among other
problems.
This is important because mypy doesn't generally think functions are compatible with `FunctionType`, so `inspect.getsource` on arbitrary functions is rejected by the current annotations.
The annotations, formatarg, formatvarargs, formatvarkw, formatvalue,
formatreturns, and formatannotations arguments to inspect.formatargspec
have default values, but they cannot be None.
* add inspect.{isasyncgenfunction,isasyncgen} (3.6)
* reorder inspect.CO_* as in Python 3.6 doc
* add inspect.CO_{COROUTINE,ITERABLE_COROUTINE} (3.5)
* add inspect.CO_ASYNC_GENERATOR (3.6)
* use variable annotations
* use version checks
* Parameter.empty is a class attribute
* Signature.empty is a class attribute
This is in our style guide. This is the last piece of offending code; I just submitted ambv/flake8-pyi#10 to enforce the rule in the linter in the future.
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.
This is follow-up to a similar commit improving Python 2.7 inspect stub[1].
Similarly, this commit consists of:
* Splitting and reordering the content into sections corresponding
to the module's documentation sections
* Implementing missing functions, classes etc.
* Adding TODOs for things that are either difficult to get or I can't
figure them out right now
* Making the existing code consistent with the newly added things
As suggested in pull request #108 I'm modifying the generic Python 3
stub even though some things changed and were added in various Python
3.x releases - the changes seem to be backwards compatible and the
additions, well, they should not break much except for some false
positives on older Python 3 versions.
Some of the types in this stub were not obvious so I either read the
source code or used my judgment.
[1] 630f718376