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

String forward reference support - #1441

Merged
Cameron Trando (CTrando) merged 11 commits into
microsoft:masterfrom
CTrando:scratch/GenericForwardRef
Aug 28, 2019
Merged

Cameron Trando (CTrando) merged 11 commits into
microsoft:masterfrom
CTrando:scratch/GenericForwardRef

Conversation

@CTrando

@CTrando Cameron Trando (CTrando) commented Aug 14, 2019 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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
Cameron Trando (CTrando) merged commit 5b086d8 into microsoft:master Aug 28, 2019
Jake Bailey (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

2 participants