Commit 10c8ecc
authored
Enable pretty-printing for PEP-649 annotated functions (ipython#15095)
This PR detects the possibility of such functions by importing
annotationlib.Format from inspect, and wraps inspect.signature in a
partial that sets annotation_format=Format.FORWARDREF.
This may be more proof-of-concept than final form; I won't be offended
if you want to scrap this and tackle the issue a different way :)
I'm also not sure this is actually enough to support all possibilities,
but it at least gets us from
```python
In [1]: def test(p: Annotated): pass
In [2]: test
<huge traceback elided>
NameError: name 'Annotated' is not defined
In [3]:
```
to
```python
In [1]: def test(p: Annotated): pass
In [2]: test
Out[2]: <function __main__.test(p: Annotated)>
```2 files changed
+33
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
112 | 120 | | |
113 | 121 | | |
114 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
546 | 571 | | |
547 | 572 | | |
548 | 573 | | |
| |||
0 commit comments