Victor Stinner
c6d56135e1
gh-108638: Fix tests when _stat extension is missing ( #108689 )
...
Fix test_inspect and test_pydoc when the _stat extension is missing.
Skip tests relying on _stat when _stat is missing.
2023-08-31 23:14:23 +02:00
Nikita Sobolev
3f61cf646d
gh-108303: Move `ann_module*.py` files to `typinganndata/` folder ( #108354 )
2023-08-23 17:42:08 +02:00
Serhiy Storchaka
3901c991e1
gh-84805: Autogenerate signature for METH_NOARGS and METH_O extension functions (GH-107794)
2023-08-11 18:08:38 +03:00
Tian Gao
14fbd4e6b1
gh-107446: Fix test_inspect.test_class_with_method_from_other_module when ran multiple times ( #107451 )
...
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-08-03 15:04:03 +00:00
Tian Gao
b383703491
gh-106727: Add `__module__` check for `inspect.getsource(cls)` ( #106968 )
2023-07-24 13:12:45 -07:00
Tian Gao
663854d73b
gh-106727: Make `inspect.getsource` smarter for class for same name definitions ( #106815 )
2023-07-18 23:20:31 +00:00
Inada Naoki
2566b74b26
gh-81283: compiler: remove indent from docstring ( #106411 )
...
Co-authored-by: Éric <merwok@netwok.org>
2023-07-15 19:33:32 +09:00
Tian Gao
9ad199ba36
gh-105080: Fixed inconsistent signature on derived classes ( #105217 )
2023-06-02 16:22:33 -06:00
Lysandros Nikolaou
70f315c2d6
gh-105042: Disable unmatched parens syntax error in python tokenize ( #105061 )
2023-05-30 22:52:52 +01:00
Pablo Galindo Salgado
3a5be878be
gh-105013: Fix inspect.getsource with parenthesized multiline lambdas ( #105021 )
2023-05-28 00:20:42 +01:00
Jelle Zijlstra
6e1eccdcce
gh-104955: Fix __release_buffer__ signature ( #104956 )
...
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-05-26 05:44:23 -07:00
Furkan Onder
5e9f471e7d
gh-75367: Fix data descriptor detection in inspect.getattr_static ( #104517 )
...
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-16 17:34:44 +00:00
Carl Meyer
c3b595e73e
gh-97933: (PEP 709) inline list/dict/set comprehensions ( #101441 )
...
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-09 11:02:14 -06:00
Alex Waygood
921185ed05
gh-103193: Improve `getattr_static` test coverage ( #104286 )
2023-05-08 15:18:36 +01:00
Alex Waygood
1b19bd1a88
gh-103193: cache calls to `inspect._shadowed_dict` in `inspect.getattr_static` ( #104267 )
...
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-07 18:45:09 +01:00
Nikita Sobolev
6b58d419a1
gh-103556: [inspect.Signature] disallow pos-or-kw params without default after pos-only with default ( #103557 )
2023-04-21 23:45:10 -06:00
Nikita Sobolev
4fe1c4b97e
gh-103553: Improve `test_inspect`: add more assertions, remove unused ( #103554 )
2023-04-15 13:48:31 -07:00
Nikita Sobolev
7569781176
gh-103406: Modernize pos-only arguments usage in `test_signature` ( #103407 )
2023-04-14 00:06:31 -07:00
Irit Katriel
44bd3fe570
gh-102799: use exception instance instead of sys.exc_info() ( #102885 )
2023-03-31 11:23:02 +01:00
Thomas Krennwallner
534660f168
gh-79940: skip `TestGetAsyncGenState` on wasm as it requires working sockets (GH-102605)
...
Skip `TestGetAsyncGenState` and restoring of the default event loop policy in `test_inspect` if platform lacks working socket support.
Fixes #11590
Automerge-Triggered-By: GH:kumaraditya303
2023-03-11 10:36:49 -08:00
Thomas Krennwallner
ced13c96a4
gh-79940: add introspection API for asynchronous generators to `inspect` module ( #11590 )
2023-03-11 18:49:40 +05:30
David Hewitt
71cf7c3ddd
gh-102378: don't bother stripping `/` from __text_signature__ ( #102379 )
2023-03-09 15:06:20 -08:00
Carlton Gibson
07a87f74fa
gh-94912: Adjusted check for non-standard coroutine function marker. ( #100935 )
...
The initial implementation did not correctly identify explicitly
marked class instances.
Follow up to 532aa4e4e0
2023-01-11 13:17:26 -08:00
Nikita Sobolev
9e7d7266ec
gh-96127: Fix `inspect.signature` call on mocks ( #96335 )
2023-01-07 10:49:15 +00:00
Shantanu
79311cbfe7
gh-85267: Improvements to inspect.signature __text_signature__ handling ( #98796 )
...
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`.
2022-12-20 19:29:02 -08:00
Carlton Gibson
532aa4e4e0
gh-94912: Added marker for non-standard coroutine function detection ( #99247 )
...
This introduces a new decorator `@inspect.markcoroutinefunction`,
which, applied to a sync function, makes it appear async to
`inspect.iscoroutinefunction()`.
2022-12-18 11:13:24 -08:00
Ethan Furman
a5a7cea202
gh-100039: enhance __signature__ to work with str and callables (GH-100168)
...
Callables should be either class- or static-methods.
Enum now uses the classmethod version to greatly improve the help
given for enums and flags.
2022-12-16 12:30:47 -08:00
Carl Meyer
68e41295b8
gh-83035: handle decorator with nested parens in inspect.getsource ( #99654 )
2022-12-07 08:55:12 -08:00
Anton Ryzhov
dbf2faf579
gh-74044: inspect.signature for wrappers around decorated bound methods (GH-736)
2022-11-10 12:32:01 +00:00
Frazer McLean
f4f8133387
GH-83901: Improve Signature.bind error message for missing keyword-only params ( #95347 )
...
Fixes GH-83901
2022-10-07 15:24:17 -07:00
Anh71me
d5fea01d9d
GH-96073: Fix wild replacement in inspect.formatannotation ( #96074 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-07 11:23:06 -07:00
Brett Cannon
e1c4d56fdd
gh-65961: Do not rely solely on `__cached__` (GH-97990)
...
Make sure `__spec__.cached` (at minimum) can be used.
2022-10-06 15:40:22 -07:00
Mehdi ABAAKOUK
4261b6bffc
gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock ( #94050 )
...
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>
2022-06-30 19:08:38 +02:00
Christian Heimes
9b50585e02
gh-90473: Skip tests that don't apply to Emscripten and WASI (GH-92846)
2022-05-16 16:02:37 +02:00
Zac Hatfield-Dodds
65f88a6ef7
gh-92062: `inspect.Parameter` checks whether `name` is a keyword (GH-92065)
...
Fixes #92062 .
2022-05-03 13:52:30 -07:00
Pablo Galindo Salgado
0daa99f68b
gh-88116: Enhance the inspect frame APIs to use the extended position information (GH-91531)
2022-04-23 03:16:48 +01:00
Hakan Çelik
562c13f573
bpo-29418: Implement inspect.ismethodwrapper and fix inspect.isroutine for cases where methodwrapper is given (GH-19261)
...
Automerge-Triggered-By: GH:isidentical
2022-02-16 04:46:20 -08:00
Christian Heimes
96b344c2f1
bpo-40280: Address more test failures on Emscripten (GH-31050)
...
Co-authored-by: Brett Cannon <brett@python.org>
2022-02-05 20:52:01 +01:00
Nikita Sobolev
0cbdd21311
bpo-46565: `del` loop vars that are leaking into module namespaces (GH-30993)
2022-02-03 11:20:08 +02:00
Weipeng Hong
691506f4e9
bpo-46103: Fix inspect.getmembers to only get __bases__ from class (GH-30147)
2022-01-23 09:40:38 -08:00
Weipeng Hong
881a763cfe
bpo-43118: Fix bug in inspect.signature around 'base.__text_signature__' (GH-30285)
2022-01-21 13:24:33 -08:00
Irit Katriel
a287b31bcb
bpo-46411: Remove unnecessary calls to sys.exc_info() in tests (GH-30638)
2022-01-18 07:05:16 +00:00
AN Long
f62420c3d3
Remove spaces in empty lines (GH-30121)
2021-12-16 01:35:21 +09:00
Kumar Aditya
810c1769f1
bpo-27062: add `__all__` to inspect module (GH-30003)
2021-12-11 00:05:23 +01:00
Weipeng Hong
af8c8caaf5
bpo-30533:Add function inspect.getmembers_static that does not call 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>
2021-11-30 10:23:13 -08:00
Irit Katriel
a459a81530
bpo-45406: make inspect.getmodule() return None when getabsfile() raises FileNotFoundError (GH-28824)
2021-11-02 22:55:51 +01:00
Martin Rueckl
d02ffd1b5c
bpo-45438: format of inspect.Signature with generic builtins ( #29212 )
...
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>
2021-10-27 14:36:41 -07:00
Hugo van Kemenade
d89fb9a5a6
bpo-45320: Remove long-deprecated inspect methods (GH-28618)
2021-10-20 20:48:55 +02:00
Serhiy Storchaka
40348acc18
bpo-45229: Remove test_main in many tests (GH-28405)
...
Instead of explicitly enumerate test classes for run_unittest()
use the unittest ability to discover tests. This also makes these
tests discoverable and runnable with unittest.
load_tests() can be used for dynamic generating tests and adding
doctests. setUpModule(), tearDownModule() and addModuleCleanup()
can be used for running code before and after all module tests.
2021-09-19 15:27:33 +03:00
andrei kulakov
58325971de
bpo-44808: fixes test for interactive inspect getsource of a class (GH-27571)
...
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-08-03 14:47:30 +02:00