Skip to content

Bug: stub for time.gmtime() is not working correctly #7588

Closed

Description

@jolaf

The following code:

from time import gmtime
(a, b, c, d, e, f, g, h, i) = gmtime()
print(a, b, c, d, e, f, g, h, i)

produces the following output:

$ python3 Test.py 
2019 9 30 16 29 49 0 273 0
$ mypy Test.py
Test.py:3: error: Too many values to unpack (9 expected, 11 provided)

$ mypy --version
mypy 0.730
$ python3 --version
Python 3.6.8

reveal_type(gmtime) produces the following output:
Revealed type is 'def (secs: Union[builtins.float, None] =) -> Tuple[builtins.int, builtins.int, builtins.int, builtins.int, builtins.int, builtins.int, builtins.int, builtins.int, builtins.int, builtins.str, builtins.int, fallback=time.struct_time]

Activity

  1. msullivan commented on Sep 30, 2019

    @msullivan
    Collaborator

    This seems to be a real issue that stems from all of the fields being listed as part of a namedtuple in the typeshed stub, when only 9 of them are part of the tuple and the rest are just attributes.

    The bug should be filed against typeshed, though.
    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions