Skip to content

datetime.datetime.__init__ stub bug? #814

Closed
@smontanaro

Description

@smontanaro

Stumbled on this today (Python 2 or Python 3):

print(datetime.datetime(2017, 1, 1, 12, 12, 12))
fields = [2017, 1, 1, 12, 12, 12]
print(datetime.datetime(*fields))

When run, both prints produce the expected output, but mypy complains about the second construction:

Argument 1 to "datetime" has incompatible type *List[int]; expected "tzinfo"

I'm using mypy 0.4.6 and a set of typeshed definitions I installed locally on Dec 6. Sorry I can't be more specific than that. Getting stuff into my work environment is tedious. If you can't reproduce this with the latest mypy+typeshed, just close it.

The stub for datetime.datetime.__init__ in what I have looks broken to me though. For both stdlib/2 and stdlib/3 it suggests that only the type of the year is known to be an int. Everything else other than tzinfo is given as "...". In fact, in Python 3, at least, everything after the day should be optional. Year, month, and day must be ints.

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