Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

time.strptime (and others) info not being pulled from typeshed #300

Closed

Description

time is in typeshed, where strptime is given the hint:

def strptime(string: str, format: str = ...) -> struct_time: ...

But the following pyi text is showing up in the languageServer folder instead:

def strptime(string, format):
    "strptime(string, format) -> struct_time\n\nParse a string ..." # truncated
    return ''

Meaning that all completion on its return value is str.

There are other functions which make use of struct_time, like:

def localtime(secs: Optional[float] = ...) -> struct_time: ...

Which shows up in languageServer as:

def localtime():
    "localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n                          tm_sec,tm_wday,tm_yday,tm_isdst)\n\nConvert seconds since ..." # truncated
    return tuple()

Which is sort of correct, since struct_time is a NamedTuple, but offers no completions, whereas the actual struct_time in the same pyi file actually contains the right information about its properties.

Activity

  1. MikhailArkhipov commented on Oct 24, 2018

    @MikhailArkhipov
  2. MikhailArkhipov commented on Oct 30, 2018

    @MikhailArkhipov

    So what's wrong with

    image

    image

    image

    If the case is about named tuple, then it is dupe of #15. Otherwise signatures and return types appear correct.

  3. jakebailey commented on Oct 30, 2018

    @jakebailey
    MemberAuthor

    image

    Even with #321. It claims to return struct_time in the hover, but almost everything is str, except for __new__ which says it's from struct_time.

    Now, if you assign its result, and hover:

    image

    The part where you can't complete struct_time's members is probably #15, but the fact that the analyzer is claiming it's returning a string is not.

    In no path should strptime return a str, and the typeshed for the time module says struct_time. I might be wrong about this, as I haven't yet explored that part of the code, but I think the fact that a pyi file shows up in languageServer means that it's the scraper that's doing this.

  4. MikhailArkhipov commented on Jan 30, 2019

    @MikhailArkhipov

    New LS does

    image

  5. MikhailArkhipov commented on Feb 6, 2019

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions