summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-30951: Correct co_names docstring in inspect module (GH-2743)Alex Vig2021-09-241-1/+1
|
* bpo-44648: Fix error type in inspect.getsource() in interactive session ↵andrei kulakov2021-07-301-0/+2
| | | | (GH-27171)
* bpo-40897:Give priority to using the current class constructor in ↵Weipeng Hong2021-07-161-8/+16
| | | | | `inspect.signature` (#27177) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-35113: clean up duplicate import and comment (#27073)andrei kulakov2021-07-131-4/+0
|
* bpo-20684: Remove unused inspect._signature_get_bound_param (GH-21100)Anthony Sottile2021-05-221-23/+0
|
* bpo-43817: Add inspect.get_annotations(). (#25522)larryhastings2021-04-301-14/+135
| | | | | Add inspect.get_annotations, which safely computes the annotations defined on an object. It works around the quirks of accessing the annotations from various types of objects, and makes very few assumptions about the object passed in. inspect.get_annotations can also correctly un-stringize stringized annotations. inspect.signature, inspect.from_callable, and inspect.from_function now call inspect.get_annotations to retrieve annotations. This means inspect.signature and inspect.from_callable can now un-stringize stringized annotations, too.
* bpo-38605: Revert making 'from __future__ import annotations' the default ↵Pablo Galindo2021-04-211-17/+2
| | | | | | (GH-25490) This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
* bpo-40066: Enum: modify `repr()` and `str()` (GH-22392)Ethan Furman2021-03-311-3/+0
| | | | | | | | | * Enum: streamline repr() and str(); improve docs - repr() is now ``enum_class.member_name`` - stdlib global enums are ``module_name.member_name`` - str() is now ``member_name`` - add HOW-TO section for ``Enum`` - change main documentation to be an API reference
* bpo-42901: [Enum] move member creation to `__set_name__` (GH-24196)Ethan Furman2021-01-131-1/+1
| | | | | | | | | | | `type.__new__` calls `__set_name__` and `__init_subclass__`, which means that any work metaclasses do after calling `super().__new__()` will not be available to those two methods. In particular, `Enum` classes that want to make use of `__init_subclass__` will not see any members. Almost all customization is therefore moved to before the `type.__new__()` call, including changing all members to a proto member descriptor with a `__set_name__` that will do the final conversion of a member to be an instance of the `Enum` class.
* bpo-41960: Add globalns and localns parameters to inspect.signature and ↵Batuhan Taskaya2020-12-231-49/+31
| | | | Signature.from_callable (GH-22583)
* bpo-17735: inspect.findsource now raises OSError when co_lineno is out of ↵Irit Katriel2020-12-041-1/+6
| | | | | range (GH-23633) This can happen when a file was edited after it was imported.
* bpo-42116: Fix inspect.getsource handling of trailing comments (GH-23630)Irit Katriel2020-12-041-0/+7
|
* bpo-42133: update parts of the stdlib to fall back to `__spec__.loader` when ↵Brett Cannon2020-11-071-2/+5
| | | | `__loader__` is missing (#22929)
* bpo-38605: Make 'from __future__ import annotations' the default (GH-20434)Batuhan Taskaya2020-10-061-2/+17
| | | | | The hard part was making all the tests pass; there are some subtle issues here, because apparently the future import wasn't tested very thoroughly in previous Python versions. For example, `inspect.signature()` returned type objects normally (except for forward references), but strings with the future import. We changed it to try and return type objects by calling `typing.get_type_hints()`, but fall back on returning strings if that function fails (which it may do if there are future references in the annotations that require passing in a specific namespace to resolve).
* bpo-40257: Revert changes to inspect.getdoc() (GH-20073)Serhiy Storchaka2020-05-181-17/+16
|
* bpo-35113: Fix inspect.getsource to return correct source for inner classes ↵Karthikeyan Singaravelan2020-04-181-19/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#10307) * Use ast module to find class definition * Add NEWS entry * Fix class with multiple children and move decorator code to the method * Fix PR comments 1. Use node.decorator_list to select decorators 2. Remove unwanted variables in ClassVisitor 3. Simplify stack management as per review * Add test for nested functions and async calls * Fix pydoc test since comments are returned now correctly * Set event loop policy as None to fix environment related change * Refactor visit_AsyncFunctionDef and tests * Refactor to use local variables and fix tests * Add patch attribution * Use self.addCleanup for asyncio * Rename ClassVisitor to ClassFinder and fix asyncio cleanup * Return first class inside conditional in case of multiple definitions. Remove decorator for class source. * Add docstring to make the test correct * Modify NEWS entry regarding decorators * Return decorators too for bpo-15856 * Move ast and the class source code to top. Use proper Exception.
* bpo-40257: Output object's own docstring in pydoc (GH-19479)Serhiy Storchaka2020-04-151-16/+17
|
* bpo-39957: Change Signature.parameters to OrderedDict (GH-18988)Jens Reidel2020-03-181-4/+4
|
* bpo-13487: Use sys.modules.copy() in inspect.getmodule() for thread safety. ↵Gregory P. Smith2020-03-051-1/+1
| | | | | | | | (GH-18786) `list(sys.modules.items())` was apparently not immune to "dictionary changed size during iteration" errors. Tested internally using an integration test that has run into this a couple of times in the past two years. With this patch applied, the test is no longer flaky.
* bpo-39775: inspect: Change Signature.parameters back to OrderedDict. (GH-18684)Inada Naoki2020-03-021-10/+12
|
* bpo-36350: inspect: Replace OrderedDict with dict. (GH-12412)Rémi Lapeyre2020-01-281-21/+18
|
* Remove unnecessary variable definition (GH-17368)Batuhan Taşkaya2019-11-241-1/+0
|
* bpo-38478: Correctly handle keyword argument with same name as ↵Pablo Galindo2019-10-151-1/+1
| | | | positional-only parameter (GH-16800)
* bpo-34706: Preserve subclassing in inspect.Signature.from_callable (GH-16108)Gregory P. Smith2019-09-131-1/+1
| | | | | | | | https://bugs.python.org/issue34706 Specifically in the case of a class that does not override its constructor signature inherited from object. These are Buck Evan @bukzor's changes cherrypicked from GH-9344.
* bpo-38059: Using sys.exit() over exit() in inspect.py (GH-15666)Alan Yee2019-09-091-2/+2
| | | Constants added by the site module like exit() "should not be used in programs"
* bpo-38026: fix inspect.getattr_static (GH-15676)Inada Naoki2019-09-051-2/+2
| | | | | It should avoid dynamic lookup including `isinstance`. This is a regression caused by GH-5351.
* bpo-37173: Show passed class in inspect.getfile error (GH-13861)Philipp A2019-06-081-3/+3
| | | | | | | | | | | | | Currently, inspect.getfile(str) will report nonsense: ```pytb >>> inspect.getfile(str) TypeError: <module 'builtins' (built-in)> is a built-in class ``` This fixes that https://bugs.python.org/issue37173
* bpo-37122: Make co->co_argcount represent the total number of positonal ↵Pablo Galindo2019-06-011-18/+10
| | | | arguments in the code object (GH-13726)
* bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)Serhiy Storchaka2019-06-011-7/+5
|
* bpo-36751: Undeprecate getfullargspec (GH-13245)Pablo Galindo2019-05-161-6/+0
|
* bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705)Serhiy Storchaka2019-05-061-2/+7
|
* MNT: set stacklevel in the getfullargspec deprecation warning to 2 (GH-13029)Thomas A Caswell2019-05-011-1/+1
| | | | | | This is consistent with the rest of the `warnings.warn` usage in the inspect.py module and aids identifying code that needs to be fixed. This warning came in via d5d2b4546939b98244708e5bb0cfccd55b99d244
* bpo-36751: Deprecate getfullargspec and report positional-only args as ↵Pablo Galindo2019-04-301-25/+18
| | | | | | | | regular args (GH-13016) * bpo-36751: Deprecate getfullargspec and report positional-only args as regular args * Use inspect.signature in testhelpers
* bpo-36540: PEP 570 -- Implementation (GH-12701)Pablo Galindo2019-04-291-37/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit contains the implementation of PEP570: Python positional-only parameters. * Update Grammar/Grammar with new typedarglist and varargslist * Regenerate grammar files * Update and regenerate AST related files * Update code object * Update marshal.c * Update compiler and symtable * Regenerate importlib files * Update callable objects * Implement positional-only args logic in ceval.c * Regenerate frozen data * Update standard library to account for positional-only args * Add test file for positional-only args * Update other test files to account for positional-only args * Add News entry * Update inspect module and related tests
* bpo-33261: guard access to __code__ attribute in inspect (GH-6448)Jeroen Demeyer2019-04-021-9/+14
|
* bpo-36326: Let inspect.getdoc() find docstrings for __slots__ (GH-12498)Raymond Hettinger2019-03-251-1/+4
|
* bpo-34890: Make iscoroutinefunction, isgeneratorfunction and ↵Pablo Galindo2018-10-261-9/+12
| | | | | | | | | | | isasyncgenfunction work with functools.partial (GH-9903) inspect.isfunction() processes both inspect.isfunction(func) and inspect.isfunction(partial(func, arg)) correctly but some other functions in the inspect module (iscoroutinefunction, isgeneratorfunction and isasyncgenfunction) lack this functionality. This commits adds a new check in the mentioned functions in the inspect module so they can work correctly with arbitrarily nested partial functions.
* bpo-33594: Add deprecation info in inspect.py module (GH-7036)Matthias Bussonnier2018-10-191-7/+15
|
* bpo-34871: inspect: Don't pollute sys.modules (GH-9696)INADA Naoki2018-10-041-1/+1
| | | https://bugs.python.org/issue34871
* bpo-32892: Use ast.Constant instead of specific constant AST types. (GH-9445)Serhiy Storchaka2018-09-271-8/+2
|
* bpo-6700: Fix inspect.getsourcelines for module level frames/tracebacks ↵Vladimir Matveev2018-08-241-1/+6
| | | | (GH-8864)
* bpo-33582: Remove duplicate space in inspect.formatargspec() deprecation ↵Zackery Spytz2018-06-121-1/+1
| | | | warning (GH-7655)
* bpo-33582: Emit deprecation warning for `formatargspec` (GH-6994)Matthias Bussonnier2018-06-111-2/+14
|
* bpo-33197: Add description property for _ParameterKind. (GH-7206)Dong-hee Na2018-06-081-6/+7
|
* bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636)Dong-hee Na2018-05-291-16/+31
|
* bpo-26103: Fix inspect.isdatadescriptor() and a data descriptor definition. ↵Aaron Hall, MBA2018-05-201-2/+2
| | | | | | (GH-1959) Look for '__set__' or '__delete__'.
* bpo-33009: Fix inspect.signature() for single-parameter partialmethods. ↵Yury Selivanov2018-03-061-1/+2
| | | | (GH-6004)
* bpo-32991: Restore expectation that inspect.getfile raises TypeError on ↵Jason R. Coombs2018-03-051-2/+2
| | | | | | | | | | namespace package (GH-5980) * bpo-32991: Add test capturing expectation. DocTestFinder.find should return an empty list for doctests in a namespace package. * bpo-32991: Restore expectation that inspect.getfile on a namespace package raises TypeError.
* Cleanup inspectSrinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి)2018-02-091-4/+4
| | | | * use isinstance(..) instead of type(..) * use '.. not in ..' instead of 'not .. in .. '
* bpo-32678: inspect: Import ast lazily (GH-5344)INADA Naoki2018-01-271-1/+3
|