You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
String forward references not working as generic type parameters #1186
When using "stringy" types such as List["SomeClass"] and a for loop over that (or any other operation that returns the element type), the element in the loop is not resolved as type SomeClass
Full repro example (see the comments for where the issue appears):
fromtypingimportListclassBar:
defbar_method(self) ->int:
return1deflist_of_bars() ->List["Bar"]:
return []
defno_string_list_of_bars() ->List[Bar]:
return []
defa_single_bar() ->"Bar":
returnBar()
deftest():
single=a_single_bar()
single.bar_method()
l=list_of_bars()
foriteminl: # Hover: Type of item is unresolveditem.bar_method() # Go to definition does not workl2=no_string_list_of_bars()
foritem2inl2: # Type is resolved hereitem2.bar_method() # Ctrl+click works
Extension information:
Microsoft Python Language Server version 0.2.96.0
Name: Python
Id: ms-python.python
Description: Linting, Debugging (multi-threaded, remote), Intellisense, code formatting, refactoring, unit tests, snippets, and more.
Version: 2019.5.18875
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python
changed the title [-]String forward references not working as generic type parameters in `for`[/-][+]String forward references not working as generic type parameters[/+]on Jun 13, 2019
Activity
jaens commentedon Jun 13, 2019
Looks like this applies to any operation on generic types, not just for loops (eg. indexing).
[-]String forward references not working as generic type parameters in `for`[/-][+]String forward references not working as generic type parameters[/+]