Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pexpect - wrong annotation on timeout spawn class argument #11239

Closed
renatoGarcia opened this issue Jan 4, 2024 · 1 comment · Fixed by #11240
Closed

pexpect - wrong annotation on timeout spawn class argument #11239

renatoGarcia opened this issue Jan 4, 2024 · 1 comment · Fixed by #11240
Labels
type-false-positive Type checkers report false errors

Comments

@renatoGarcia
Copy link
Contributor

renatoGarcia commented Jan 4, 2024

On annotation for timeout argument of spawn class __init__ method, it is being set as int only. However, it shold be float | None as in documentation.

The change from int to float is justified both from documentation referring to it as "number", as with it being possibly forwarded to asyncio.wait_for function, that accept it as a float.

renatoGarcia added a commit to renatoGarcia/typeshed that referenced this issue Jan 4, 2024
@srittau srittau added the type-false-positive Type checkers report false errors label Jan 5, 2024
@gareth-rees
Copy link

Two other code paths where it makes sense for timeout to be a float are:

  1. In poll_ignore_interrupts where timeout is multiplied by 1000 to get a value in milliseconds for passing to select.poll.poll:

    timeout_ms = None if timeout is None else timeout * 1000
    results = poller.poll(timeout_ms)
    

    If timeout is required to be int then it is impossible to specify sub-second timeouts even though these are supported by select.poll.poll.

  2. In select_ignore_interrupts where timeout is passed to select.select:

    return select.select(iwtd, owtd, ewtd, timeout)
    

    The select.select documentation says, "The optional timeout argument specifies a time-out as a floating point number in seconds".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-false-positive Type checkers report false errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants