Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show fancy type hints #77

Open
zsol opened this issue Aug 15, 2022 · 1 comment
Open

Show fancy type hints #77

zsol opened this issue Aug 15, 2022 · 1 comment

Comments

@zsol
Copy link
Owner

zsol commented Aug 15, 2022

Instead of

Callable[[a, b], c]
Union[a, b]

Let's show

(a, b) -> c
a | b

And maybe even

Tuple[a, b, ...]
# should turn into
(a, b, ...)
@zsol
Copy link
Owner Author

zsol commented Aug 15, 2022

One approach on the indexer side is to introduce

Annotation = Arrow | Bars | Type

@dataclass
class Arrow:
  params: list[Annotation]
  returns: Annotation

@dataclass
class Bars:
  terms: list[Annotation]  # always at least 2 items

And then the indexer would translate all Union[...] and Callable[...] annotations into Bars and Arrow structures. This would get rid of the ugly edge case described in #8 for callables:

Callable[[], returns]

# =>

Type("Callable", xref, params=[
  Type("", None, params=[]),  # this would no longer happen
  Type("returns", None, None),
])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant