summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-127610: Added validation for more than one var-positional and var-keyword ↵Apostol Fet2024-12-081-0/+8
| | | | parameters in inspect.Signature (GH-127657)
* gh-70764: inspect.getclosurevars now identifies global variables with ↵blhsing2024-11-051-5/+9
| | | | LOAD_GLOBAL (#120143)
* gh-126072: do not add `None` to `co_consts` if there is no docstring (GH-126101)Xuanteng Huang2024-10-301-0/+2
|
* gh-125633: Add function `ispackage` to stdlib `inspect` (#125634)Zhikang Yan2024-10-271-3/+8
| | | | | --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-101552: Allow pydoc to display signatures in source format (#124669)Jelle Zijlstra2024-10-091-15/+37
| | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-116110: remove extra processing for the __signature__ attribute (GH-116234)Sergey B Kirpichev2024-10-081-9/+1
| | | This is an alternative to GH-100168.
* gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in ↵Serhiy Storchaka2024-09-281-2/+4
| | | | | | | | | | | | | classes (GH-123613) * Setting the __module__ attribute for a class now removes the __firstlineno__ item from the type's dict. * The _collections_abc and _pydecimal modules now completely replace the collections.abc and decimal modules after importing them. This allows to get the source of classes and functions defined in these modules. * inspect.findsource() now checks whether the first line number for a class is out of bound.
* gh-119127: functools.partial placeholders (gh-119827)dgpb2024-09-261-2/+22
|
* gh-122981: Fix inspect.getsource() for generated classes with Python base ↵Serhiy Storchaka2024-08-201-3/+3
| | | | | | classes (GH-123001) Look up __firstlineno__ only in the class' dict, without searching in base classes.
* gh-119180: annotationlib: Fix __all__, formatting (#122365)Jelle Zijlstra2024-08-111-3/+1
|
* gh-122058: `Lib/inspect`: Update docstrings for `isfunction`, `isgenerator`, ↵Kirill Podoprigora2024-08-061-9/+24
| | | | | | `isframe`, `iscode`. (#122059) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-119180: Add `annotationlib` module to support PEP 649 (#119891)Jelle Zijlstra2024-07-231-115/+1
| | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-121027: Add a future warning in functools.partial.__get__ (#121086)Serhiy Storchaka2024-06-271-4/+4
|
* gh-120381: Fix inspect.ismethoddescriptor() (#120383)Jan Kaliszewski2024-06-181-4/+7
| | | | | | | | The `inspect.ismethoddescriptor()` function did not check for the lack of `__delete__()` and, consequently, erroneously returned True when applied to *data* descriptors with only `__get__()` and `__delete__()` defined. Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
* gh-114053: Fix bad interaction of PEP 695, PEP 563 and ↵Alex Waygood2024-06-131-1/+7
| | | | `inspect.get_annotations` (#120270)
* gh-119180: PEP 649 compiler changes (#119361)Jelle Zijlstra2024-06-111-7/+1
|
* gh-120200: Fix `inspect.iscoroutinefunction(inspect) is True` corner case ↵Nikita Sobolev2024-06-071-3/+3
| | | | (#120214)
* gh-87106: Fix inspect.signature.bind() handling of positional-only arguments ↵Jacob Walls2024-05-131-12/+16
| | | | with **kwargs (GH-103404)
* gh-118465: Add __firstlineno__ attribute to class (GH-118475)Serhiy Storchaka2024-05-061-78/+5
| | | | It is set by compiler with the line number of the first line of the class definition.
* gh-82062: Fix support of parameter defaults on methods in extension modules ↵Sergey B Kirpichev2024-05-021-0/+5
| | | | | | | | | (GH-115270) Now inspect.signature() supports references to the module globals in parameter defaults on methods in extension modules. Previously it was only supported in functions. The workaround was to specify the fully qualified name, including the module name.
* gh-118404: Fix inspect.signature() for non-comparable callables (GH-118405)Serhiy Storchaka2024-04-301-2/+4
|
* gh-118285: Fix signatures of operator.{attrgetter,itemgetter,methodcaller} ↵Serhiy Storchaka2024-04-291-0/+7
| | | | | | | | | instances (GH-118316) * Allow to specify the signature of custom callable instances of extension type by the __text_signature__ attribute. * Specify signatures of operator.attrgetter, operator.itemgetter, and operator.methodcaller instances.
* gh-118013: Use weakrefs for the cache key in `inspect._shadowed_dict` (#118202)Alex Waygood2024-04-241-3/+22
|
* gh-116987: Support class code objects in inspect.findsource() (GH-117025)Tian Gao2024-03-211-9/+2
|
* gh-114099 - Add iOS framework loading machinery. (GH-116454)Russell Keith-Magee2024-03-191-1/+6
| | | | Co-authored-by: Malcolm Smith <smith@chaquo.com> Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-101293: Fix support of custom callables and types in ↵Serhiy Storchaka2024-03-011-87/+74
| | | | | | | | | | | inspect.Signature.from_callable() (GH-115530) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors.
* gh-112006: Fix inspect.unwrap() for types where __wrapped__ is a data ↵Serhiy Storchaka2024-02-261-7/+3
| | | | | | descriptor (GH-115540) This also fixes inspect.Signature.from_callable() for builtins classmethod() and staticmethod().
* gh-101860: Expose __name__ on property (GH-101876)Eugene Toder2024-02-201-3/+2
| | | | | Useful for introspection and consistent with functions and other descriptors.
* bpo-38364: unwrap partialmethods just like we unwrap partials (#16600)Martijn Pieters2024-02-151-2/+4
| | | | | | | | | | | | | * bpo-38364: unwrap partialmethods just like we unwrap partials The inspect.isgeneratorfunction, inspect.iscoroutinefunction and inspect.isasyncgenfunction already unwrap functools.partial objects, this patch adds support for partialmethod objects as well. Also: Rename _partialmethod to __partialmethod__. Since we're checking this attribute on arbitrary function-like objects, we should use the namespace reserved for core Python. --------- Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-112316: improve docs for `inspect.signature` and `inspect.Signature` ↵Alex Waygood2023-12-031-1/+1
| | | | (#112631)
* gh-112139: Add `inspect.Signature.format` and use it in `pydoc` (#112143)Nikita Sobolev2023-12-021-0/+12
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-108751: Add copy.replace() function (GH-108752)Serhiy Storchaka2023-09-061-0/+4
| | | | | | | | | It creates a modified copy of an object by calling the object's __replace__() method. It is a generalization of dataclasses.replace(), named tuple's _replace() method and replace() methods in various classes, and supports all these stdlib classes.
* gh-106727: Add `__module__` check for `inspect.getsource(cls)` (#106968)Tian Gao2023-07-241-1/+2
|
* gh-106727: Make `inspect.getsource` smarter for class for same name ↵Tian Gao2023-07-181-11/+46
| | | | definitions (#106815)
* gh-81283: compiler: remove indent from docstring (#106411)Inada Naoki2023-07-151-23/+22
| | | Co-authored-by: Éric <merwok@netwok.org>
* gh-105080: Fixed inconsistent signature on derived classes (#105217)Tian Gao2023-06-021-11/+12
|
* gh-105069: Add a readline-like callable to the tokenizer to consume input ↵Pablo Galindo Salgado2023-05-301-1/+1
| | | | iteratively (#105070)
* gh-105013: Fix inspect.getsource with parenthesized multiline lambdas (#105021)Pablo Galindo Salgado2023-05-271-0/+8
|
* gh-102856: Python tokenizer implementation for PEP 701 (#104323)Marta Gómez Macías2023-05-211-2/+2
| | | | | | | | | | | This commit replaces the Python implementation of the tokenize module with an implementation that reuses the real C tokenizer via a private extension module. The tokenize module now implements a compatibility layer that transforms tokens from the C tokenizer into Python tokenize tokens for backward compatibility. As the C tokenizer does not emit some tokens that the Python tokenizer provides (such as comments and non-semantic newlines), a new special mode has been added to the C tokenizer mode that currently is only used via the extension module that exposes it to the Python layer. This new mode forces the C tokenizer to emit these new extra tokens and add the appropriate metadata that is needed to match the old Python implementation. Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* gh-75367: Fix data descriptor detection in inspect.getattr_static (#104517)Furkan Onder2023-05-161-2/+4
| | | Co-authored-by: Carl Meyer <carl@oddbird.net>
* gh-103193: cache calls to `inspect._shadowed_dict` in ↵Alex Waygood2023-05-071-2/+6
| | | | | `inspect.getattr_static` (#104267) Co-authored-by: Carl Meyer <carl@oddbird.net>
* gh-102500: Implement PEP 688 (#102521)Jelle Zijlstra2023-05-041-0/+23
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-102799: replace sys.exc_info by sys.exception in inspect and traceback ↵Irit Katriel2023-05-011-1/+3
| | | | modules (#104032)
* gh-103556: [inspect.Signature] disallow pos-or-kw params without default ↵Nikita Sobolev2023-04-221-6/+4
| | | | after pos-only with default (#103557)
* gh-103193: Speedup and inline `inspect._is_type` (#103321)Alex Waygood2023-04-061-9/+4
| | | Improve performance of `inspect.getattr_static`
* gh-103193: Use LBYL idioms rather than EAFP in `inspect.getattr_static` ↵Alex Waygood2023-04-061-15/+10
| | | | (#103318)
* gh-103193: Micro-optimise helper functions for `inspect.getattr_static` ↵Alex Waygood2023-04-051-4/+3
| | | | (#103195)
* gh-79940: add introspection API for asynchronous generators to `inspect` ↵Thomas Krennwallner2023-03-111-0/+50
| | | | module (#11590)
* gh-102378: don't bother stripping `/` from __text_signature__ (#102379)David Hewitt2023-03-091-40/+17
|
* gh-102302 Micro-optimize `inspect.Parameter.__hash__` (#102303)Gouvernathor2023-03-041-1/+1
|