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

Conversation

@CTrando
Copy link
Contributor

@CTrando CTrando commented Aug 14, 2019

Fixes #1186.
Handles cases such as:

class A: ...
class Bar: ...
def tmp(v: 'List[str]') -> 'List[str]'
def tmp(v: 'Bar') -> List['Bar']
def tmp(v: 'str') -> 'A'

So instead of returning unknown, we try to evaluate what is inside the quotes.

  • Updated the type annotation hint code to handle forward references so parameters get the correct types.
  • Handled values in quotes when creating Generic types
  • Handled forward reference return value hints

@CTrando
Copy link
Contributor Author

CTrando commented Aug 23, 2019

I updated the tests because the return documentation for a method inside a class is our own analyzed return value, but for unbound functions, we just use the regular return documentation. I think to be consistent we should also return our analyzed return value.

@CTrando CTrando force-pushed the scratch/GenericForwardRef branch from 9ad59f6 to 1ff65da Compare August 23, 2019 17:40
@CTrando CTrando merged commit 5b086d8 into microsoft:master Aug 28, 2019
jakebailey pushed a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 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

Successfully merging this pull request may close these issues.

String forward references not working as generic type parameters

2 participants