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

Support richer type annotations #273

Closed

Description

@shadow-light

Description

Richer type annotations are not supported yet.

Steps to Reproduce

variable:str = 'hi'
def task(arg:special[str]) -> something.something[str, abc.xyz, int]:
    pass

Expected behavior: All of the given type annotations should be marked
Actual behavior: None of them are marked properly

Versions

50aa96b

Additional Information

I've created a very permissive regex that works for me, but definitely needs improving before production.

Activity

  1. nicktimko commented on Mar 22, 2019

    @nicktimko
    Contributor

    What does it mean to "mark" the annotations? I'm not that familiar with the the syntax highlighting, but I think one stage of it tags text as being an operator, numeric literal, string, keyword, etc., then the theme highlights based on matching those.

    Within the arbitrary expression that the type annotations are, it appears to highlight the elements of the expression akin to any other, str, int are builtins, datetime.datetime isn't so it's just "normal". The typing helpers are in the same boat, otherwise "normal" like any non builtin, non keyword.

    image

    import datetime
    import typing
    
    class MyDate:
        @classmethod
        def from_datetime(cls, dt: datetime.datetime, do_it: bool = False) -> "MyDate":
            ...
    
        def __init__(
            self, foo: str, bar: typing.Union[None, typing.Iterable, int] = None
        ) -> None:
            ...

    What should that look like?

  2. shadow-light commented on Mar 26, 2019

    @shadow-light
    Author

    Oh, by "mark" I meant "tag" with a class.

    While types are somewhat just arbitrary code they are also indeed types as well, and it would be helpful to mark them as types as well as whatever thing they are normally. In my case I'd like to put a lower opacity on them so my eyes can naturally ignore them while I focus on actual code.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions