Repository navigation
Fix handling of generics and type declarations - #321
Conversation
|
You might want to add some tests for from typing import Sequence, TypeVar
T = TypeVar('T') # Declare type variable
def first(l: Sequence[T]) -> T: # Generic function
return l[0]
arr = [1, 2, 3]
x = first(arr) # should be int |
|
Jake Bailey (@jakebailey) - test added. |
|
(Forgive me, I started writing this comment and it blew up to be larger than expected...) That example I gave does seem to work, but when I actually run it in the editor, I see more than just I think the fact that "The most base type" is getting added means that Also, I can add the following: arr2 = ["a", "b", "c"]
y = first(arr2)And hovering over Which I find to be a little goofy because:
I guess this is due to the fact that we're combining sets of types, and Comparing this behavior to what's already in (I'd also hoped that the hover would show something like |
|
It is by design as all types are currently stored, so yet, it is Changing type merging for visual display would be a different task and large amount of work. |
Fix handling of generics and type declarations



Fixes #254
Fixes #260
#254 - Declare protocol that delegates to actual type fully.
#260 - Declare ListProtocol and DictProtocol delegating member fetching to actual underlying types but leaving actual work to
IterableandMappingprotocols respectively as it used to be.Will split Protocols files into separate classes before merging