File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import asyncio
19
19
from functools import partial , wraps
20
+ from inspect import signature
20
21
import os
21
22
from pathlib import Path
22
23
from typing import List , Union
@@ -262,10 +263,22 @@ def __str__(self):
262
263
def __repr__ (self ):
263
264
return _AsyncPipe (self .func ).__repr__ ()
264
265
266
+ @property
267
+ def __name__ (self ):
268
+ return self .func .__name__
269
+
265
270
@property
266
271
def __doc__ (self ):
267
272
return self .func .__doc__
268
273
274
+ @property
275
+ def __signature__ (self ):
276
+ return signature (self .func )
277
+
278
+ @property
279
+ def __annotations__ (self ):
280
+ return self .func .__annotations__
281
+
269
282
270
283
def pipe (func = None , preproc = None ):
271
284
"""An asynchronous pipe implementation in pure Python.
Original file line number Diff line number Diff line change 15
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
17
17
import asyncio
18
+ from inspect import signature
18
19
import logging
19
20
from pathlib import Path
20
21
from random import random
@@ -209,14 +210,17 @@ def test_pipe_brackets():
209
210
210
211
211
212
@pipe
212
- async def documented (x ):
213
+ async def documented (x : str , y : int = 0 ):
213
214
"""The docstring for the pipe function."""
214
215
pass
215
216
216
217
217
218
def test_documentation ():
218
- """It should preserve the docstring of pipe functions."""
219
+ """It should preserve the docstring, signature & annotations of
220
+ the wrapped function."""
219
221
assert documented .__doc__ == 'The docstring for the pipe function.'
222
+ assert documented .__annotations__ == {'x' : str , 'y' : int }
223
+ assert str (signature (documented )) == '(x: str, y: int = 0)'
220
224
221
225
222
226
def test_rewind ():
You can’t perform that action at this time.
0 commit comments