Commit Graph

38 Commits

Author SHA1 Message Date
Shantanu
5884ee2977 inspect: minor improvements (#4499)
Co-authored-by: hauntsaninja <>
2020-08-31 14:23:01 -07:00
Jelle Zijlstra
5f9fd3d127 upgrade black version (#4486)
Manually removed a number of trailing commas to prevent black from unnecessarily
exploding some collections.
2020-08-26 18:36:01 +02:00
Ran Benita
cd132ff161 stdlib/3/inspect: fix _ParameterKind being an empty enum (#4383)
This makes mypy think that conditions like

    parameter.kind is Parameter.POSITIONAL_OR_KEYWORD

are always false, which triggers `unreachable` warnings, among other
problems.
2020-08-04 11:02:36 +02: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
Jukka Lehtosalo
5162c536c8 Make attributes of inspect.ArgSpec optional in Python 3 (#3838)
This makes them consistent with Python 2 stubs.

The attributes are documented here:
https://docs.python.org/3/library/inspect.html#inspect.getargspec
2020-03-10 13:15:20 +01:00
Shantanu
ff7680cbfe inspect: various fixes (#3757)
* inspect: fix BlockFinder.tokeneater args

* inspect: fix formatargspec

* inspect: fix formatargvalues

* inspect: fix various arg names

* inspect: update whitelists
2020-02-21 21:23:21 -08:00
Oleg Höfling
02784bb068 inspect._ParameterKind subclasses from enum.IntEnum (#3750)
Closes #3467.
2020-02-21 14:30:15 +01:00
hauntsaninja
0505c100e1 inspect: update _ParameterKind for py38 (#3587) 2020-01-07 23:19:04 -08:00
Sebastian Rittau
ec7960a8cb Convert namedtuples to class syntax (#3321) 2019-10-20 10:37:33 +02:00
Árni Már Jónsson
7e99848b2c fixing https://github.com/python/typeshed/issues/3361 (#3362)
Fixes #3361
2019-10-14 15:21:00 +02:00
Jelle Zijlstra
c38cf6736e Allow callables in _SourceObjectType (#3295)
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.
2019-10-03 00:52:21 +02:00
Sebastian Rittau
c32e1e2280 Enable --disallow-any-generics for stubs (#3288) 2019-10-01 05:31:34 -07:00
Árni Már Jónsson
e0cc8bdafb inspect.Traceback/FrameInfo index/code_context attributes now Optional[] (#3265)
Resolves #3264
2019-09-26 17:13:00 +02:00
Ville Skyttä
c6cbe4da66 inspect: use more specific arg type for some source retrieve functions (#3155) 2019-07-30 17:53:56 +02:00
Sebastian Rittau
9ccf9356bf Remove Python 3.4 support (#3147)
Closes #3123
2019-07-27 10:58:21 +02:00
Ville Skyttä
bf50612d76 inspect: get{doc,comments,module,sourcefile} can return None (#3137) 2019-07-24 22:05:01 +02:00
Saul Shanabrook
38a7f14658 Bound arguments are ordered (#2998)
The `arguments` attribute of the `BoundArguments` is specified as an "ordered, mutable mapping (collections.OrderedDict)"
not just a mutable mapping: https://docs.python.org/3/library/inspect.html#inspect.BoundArguments.arguments
2019-05-18 22:00:05 +02:00
edgchen1
1989265e1f Make inspect.unwrap() stop argument optional. (#2583)
Closes #2574
2018-11-03 02:12:49 +01:00
Rebecca Chen
3d8a8ec45d Fix py3 types of inspect.FullArgSpec.var(args|kw) (#2556) 2018-10-25 10:45:59 -07:00
Yusuke Miyazaki
6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Sebastian Rittau
b05e99297c Drop Python 3.3 support from several stubs (#2266)
* Drop Python 3.3 support from importlib stubs

* Drop Python 3.3 support from html and symbol stubs
2018-06-20 16:46:11 -07:00
Daniel Li
87c296c964 Some inspect.formatargspec args cannot be None (#2212)
The annotations, formatarg, formatvarargs, formatvarkw, formatvalue,
formatreturns, and formatannotations arguments to inspect.formatargspec
have default values, but they cannot be None.
2018-06-11 08:07:47 -07:00
Froger David
ae91695fb7 Inspect (#2178)
* 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
2018-06-05 09:59:09 -07:00
Mathieu Leduc-Hamel
351d019241 Mark inspect.getmembers as Optional for both Py2 and Py3 (#2172) 2018-05-29 10:43:34 -07:00
Phillip Schanely
86f9472bc9 Correct 2 typing comments in inspect module (#2110) 2018-05-12 01:27:29 -04:00
Jelle Zijlstra
26e573ba1c change default value to ... in inspect.pyi (#1998)
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.
2018-03-28 20:24:39 -07:00
rchen152
8d46ada49d Add undocumented but occasionally used attributes to inspect.pyi. (#1864)
* Add attributes not in docs to 2/inspect.pyi.
* Add attributes not in docs to 3/inspect.pyi.
* Change list to List[Any] in 2/inspect.pyi
2018-02-14 16:20:55 +00:00
Jelle Zijlstra
54dd6ba27c Change numerous default values to ... (#1722)
This is the convention, and some default values (e.g. strings) apparently
break pytype.
2017-11-09 06:28:40 -08:00
Jelle Zijlstra
4ea798b869 inspect.getmoduleinfo was removed in 3.6 (#1318)
Compare https://docs.python.org/3.5/library/inspect.html#inspect.getmoduleinfo
and https://docs.python.org/3.6/library/inspect.html
2017-05-23 16:52:16 -07:00
Jelle Zijlstra
c1944f944e fix some missing ", ..." in tuples (#1079) 2017-03-22 21:04:39 -07:00
Jelle Zijlstra
349ff59f33 change empty bodies from "pass" to "..."
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.
2017-03-16 09:13:08 -07:00
Alvaro Caceres
f90a6d1c0e Inspect: use any instead of object (#585)
* Have inspect.getmembers' return value use Any instead of object
2016-10-06 11:36:17 -07:00
Antoine Catton
5b5135878b Typo: isis -> is (#495)
Fixes inspect.isgeneratorfunction().
2016-08-23 16:24:16 -07:00
Jakub Stasiak
ea37877558 Improve Python 3 inspect stub
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
2016-03-10 01:28:07 +01:00
Guido van Rossum
740568ed25 Use NamedTuple for inspect.ArgSpec and .FullArgSpec. 2016-01-18 16:51:23 -08:00
Ben Darnell
3a674645a5 Assorted fixes to stubs 2016-01-16 16:52:01 -05:00
Ben Longbons
793f3399a7 Stub for inspect.stack() and related classes 2015-10-12 10:35:04 -07:00
Matthias Kramm
337abed05a add (overwrite with) mypy stubs, if available 2015-09-30 09:59:44 -07:00