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

Consider showing type information in PEP 484 format #346

Closed
jakebailey opened this issue Nov 5, 2018 · 1 comment
Closed

Consider showing type information in PEP 484 format #346

jakebailey opened this issue Nov 5, 2018 · 1 comment
Assignees
Milestone

Comments

@jakebailey
Copy link
Member

jakebailey commented Nov 5, 2018

An example of the current behavior:

image

When we show list[int, int], what we mean is that it's a list with two items, both of type int. However, if I go write a function which would accept this variable, I would actually write:

from typing import List

def print_odd_even(l: List[List[int]]):
    for l2 in l:
        for x in l2:
        print(x, "is even" if x % 2 == 0 else "is odd")

These two syntaxes are nearly identical, and I think that even though the current behavior is more "exact", the conflict between the official type hint syntax may cause confusion as we improve our support for typing/generics.

I think it's worth figuring out if we should stop including the extra info we have in its current form, and maybe try to figure out some better way to show the info that doesn't conflict with the standard way of writing types in PEP 484.

@jakebailey
Copy link
Member Author

In the new language server, things are shown much more closely (with hints, identically) to PEP 484/typing.

image

The original example of foo = [[1, 2], [3, 4]] just shows list instead (as it is a specific instance of the real list type. There may be some loss or tooltip change that can be made to better display lists of known-consistent types, which I've opened as #605.

@jakebailey jakebailey added this to the Feb 2019.1 milestone Feb 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant