In C# it's possible to "suggest" which type a generic function uses by manually supplying it, instead of letting the compiler guess it from context. So a method T func<T>() would return a string if used like var x = func<String>(). I'm looking for the same effect for type hinting purposes in VSCode. The reason being, that I have a lookup function that returns a tkinter.Widget, but depending on which Widget it looks up, it could be any variant of that. While just having the method type hinted as -> tkinter.Widget: works for the majority of properties, I'd like to be able to specifically tell VSCode which type to expect to get specific properties too. I've found out that I can "force" a type onto a variable, by using widget: tkinter.Label = getWidget() to tell VSCode that the result is to be treated as a tkinter.Label, but at this point I'm simply curious if an approach closer to C#'s, maybe with an optional named parameter, exists as well. I've found some posts about typing.TypeVar, but I'm not fully getting yet how that works nor if it's even relevant to what I'm looking for. Edit: code example from C# public class JsonConfig { public static T Load<T>(string jsonFile = null) { ... } } This is a snippet from a class I wrote to easily use Newtonsoft.Json for (de)serializing my own simple settings classes. The useful part about C#'s Generics is that this method can accept any class I throw at it at runtime, as long as the underlying (de)serializer can make sense of it. In my case this meant any simple datatype up to Dictionary<T,T> and List<T> and any structure that can be constructed with those. If I call the method like var data = ConfigInstance.Load<List<String>>(); then the IDE knows that the expected result ending up in the variable must be List<String> and from there on treats the variable as such for intellisense etc. In VSCode Python the closest I got to this behaviour is setting a default return type like def Load(jsonFile: str = None) -> tkinter.Widget: ... and if needed "forcing" the variable I'm loading into to take the expected derived type frame: tkinter.Frame = Load() At this point I'm just wondering if there's another approach to this, maybe by providing the expected return type with a named variable, or however Pylance does type hinting in VSCode. Continue reading...