bpo-31938: Fix default-value signatures of several functions in the select module by asottile · Pull Request #21066 · python/cpython (original) (raw)

Oops, I didn't notice that you proposed a PR and so I wrote PR #21067 which is the same fix :-) Copy of my comment there.

inspect.signature() doesn't see the event_mask. Is it a bug in signature which doesn't support a signature written on two lines?

cc @serhiy-storchaka @1st1 @ambv

11:47:01 vstinner@apu$ ./python 
Python 3.10.0a0 (heads/pydoc_select:486e11db95, Jun 23 2020, 11:45:39) 
>>> import select
>>> select.epoll.register.__text_signature__
'($self, /, fd,\n         eventmask=select.EPOLLIN | select.EPOLLPRI | select.EPOLLOUT)'

>>> import inspect
>>> inspect.signature(select.epoll.register)
<Signature (self, /, fd)>

So pydoc doesn't show the whole signature:

./python -m pydoc select
(...)
     |  register(self, /, fd)
     |      Registers a new fd or raises an OSError if the fd is already registered.
     |      
     |        fd
     |          the target file descriptor of the operation
     |        eventmask
     |          a bit set composed of the various EPOLL constants
     |      
     |      The epoll interface supports all file descriptors that support poll.