| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
definitions (#106815)
|
|
|
| |
Co-authored-by: Éric <merwok@netwok.org>
|
| |
|
|
|
|
| |
iteratively (#105070)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
| |
Co-authored-by: Carl Meyer <carl@oddbird.net>
|
|
|
|
|
| |
`inspect.getattr_static` (#104267)
Co-authored-by: Carl Meyer <carl@oddbird.net>
|
|
|
| |
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
|
|
|
|
| |
modules (#104032)
|
|
|
|
| |
after pos-only with default (#103557)
|
|
|
| |
Improve performance of `inspect.getattr_static`
|
|
|
|
| |
(#103318)
|
|
|
|
| |
(#103195)
|
|
|
|
| |
module (#11590)
|
| |
|
| |
|
|
|
|
|
|
| |
The initial implementation did not correctly identify explicitly
marked class instances.
Follow up to 532aa4e4e019812d0388920768ede7c04232ebe1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This makes a couple related changes to inspect.signature's behaviour
when parsing a signature from `__text_signature__`.
First, `inspect.signature` is documented as only raising ValueError or
TypeError. However, in some cases, we could raise RuntimeError. This PR
changes that, thereby fixing #83685.
(Note that the new ValueErrors in RewriteSymbolics are caught and then
reraised with a message)
Second, `inspect.signature` could randomly drop parameters that it
didn't understand (corresponding to `return None` in the `p` function).
This is the core issue in #85267. I think this is very surprising
behaviour and it seems better to fail outright.
Third, adding this new failure broke a couple tests. To fix them (and to
e.g. allow `inspect.signature(select.epoll.register)` as in #85267), I
add constant folding of a couple binary operations to RewriteSymbolics.
(There's some discussion of making signature expression evaluation
arbitrary powerful in #68155. I think that's out of scope. The
additional constant folding here is pretty straightforward, useful, and
not much of a slippery slope)
Fourth, while #85267 is incorrect about the cause of the issue, it turns
out if you had consecutive newlines in __text_signature__, you'd get
`tokenize.TokenError`.
Finally, the `if name is invalid:` code path was dead, since
`parse_name` never returned `invalid`.
|
|
|
|
|
| |
This introduces a new decorator `@inspect.markcoroutinefunction`,
which, applied to a sync function, makes it appear async to
`inspect.iscoroutinefunction()`.
|
|
|
|
|
| |
Callables should be either class- or static-methods.
Enum now uses the classmethod version to greatly improve the help
given for enums and flags.
|
| |
|
|
|
| |
Closes #99677
|
|
|
|
| |
in inspect.signature parsing (GH-21104)
|
| |
|
| |
|
|
|
|
|
|
| |
params (#95347)
Fixes GH-83901
|
|
|
| |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
|
|
| |
Make sure `__spec__.cached` (at minimum) can be used.
|
|
|
|
|
|
|
|
|
|
| |
* inspect.getsource: avoid stat on file in linecache
The check for os.path.exists() on source file is postponed in
inspect.getsourcefile() until needed avoiding an expensive filesystem
stat call and PEP 302 module loader check is moved last for performance
since it is an uncommon case.
|
|
|
|
|
|
|
|
|
| |
The inspect version was not working with unittest.mock.AsyncMock.
The fix introduces special-casing of AsyncMock in
`inspect.iscoroutinefunction` equivalent to the one
performed in `asyncio.iscoroutinefunction`.
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
|
|
| |
Fixes #92062.
|
|
|
|
| |
information (GH-91531)
|
|
|
|
|
| |
cases where methodwrapper is given (GH-19261)
Automerge-Triggered-By: GH:isidentical
|
| |
|
| |
|
|
|
|
| |
(GH-30285)
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes.
* Trim frame and generator by word each.
* Minor refactor of frame.c
* Update test.test_sys to account for smaller frames.
* Treat generator functions as normal functions when evaluating and specializing.
|
| |
|
|
|
|
|
| |
(GH-30632)
This reverts commit acf7403f9baea3ae1119fc6b4a3298522188bf96.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Undo rejected PEP-663 changes:
- restore `repr()` to its 3.10 status
- restore `str()` to its 3.10 status
New changes:
- `IntEnum` and `IntFlag` now leave `__str__` as the original `int.__str__` so that str() and format() return the same result
- zero-valued flags without a name have a slightly changed repr(), e.g. `repr(Color(0)) == '<Color: 0>'`
- update `dir()` for mixed-in types to return all the methods and attributes of the mixed-in type
- added `_numeric_repr_` to `Flag` to control display of unnamed values
- enums without doc strings have a more comprehensive doc string added
- `ReprEnum` added -- inheriting from this makes it so only `__repr__` is replaced, not `__str__` nor `__format__`; `IntEnum`, `IntFlag`, and `StrEnum` all inherit from `ReprEnum`
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
properties or dynamic properties. (#20911)
* Add function inspect.getmembers_static that does not call properties or dynamic
properties.
* update _getmembers args
* Update Misc/NEWS.d/next/Library/2020-06-16-18-00-56.bpo-30533.StL57t.rst
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
* Update Lib/inspect.py
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
* Removes the copy pasted doc string
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
Co-authored-by: Dino Viehland <dinoviehland@gmail.com>
|
|
|
|
| |
FileNotFoundError (GH-28824)
|
|
|
|
|
|
|
| |
Use types.GenericAlias in inspect.formatannotation to correctly add
type arguments of builtin types to the string representation of
Signatures.
Co-authored-by: Martin Rückl <martin.rueckl@codecentric.de>
|
| |
|
| |
|