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.

Consider showing type information in PEP 484 format #346

Closed

Description

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.

Activity

  1. jakebailey commented on Feb 13, 2019

    @jakebailey
    MemberAuthor

    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.

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions