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

Use type hints to link function arguments and annotated assignment #108

Closed
felix-hilden opened this issue May 2, 2022 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@felix-hilden
Copy link
Owner

We should use function type hints to link argument usage. For example:

def foo(bar: Thing):
    bar.method  # links to Thing.method

I'm 90 % sure this isn't a thing yet.

@felix-hilden felix-hilden added the enhancement New feature or request label May 2, 2022
@felix-hilden
Copy link
Owner Author

The same should apply with annotated assignment:

a: Thing = b
a.method

@felix-hilden felix-hilden changed the title Use type hints to link function arguments Use type hints to link function arguments and annotated assignment May 11, 2022
@felix-hilden
Copy link
Owner Author

Some complications arise from us not executing the parsed code though. VS importable module code, which allows us to resolve string type hints and navigate hints conveniently.

One way we could limit this, would be to only accept single, direct types. Meaning no Optional/Union/List or other generics. But we'd have to recognise these hints somehow, because resolving the complex hints (i.e. taking their instance) leads to warnings down the line when the value is used. Because we don't handle subscripts, though, I think we're in the clear. A hypothetical attempt at resolving Union[A, B]().method would not produce links because the subscript stops our resolving. But I'll have to think about this some more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant