Closures and type hints (in VS Code)
When I try to type hint my closure, I get worse suggestions than without: from typing import Callable, Protocol class _FormatterProtocol(Protocol): def __call__(self, *values: object, sep: str = " ")...
View ArticleClosures and type hints (in VS Code)
When you say “suggestions”, you mean tooltips in an editor, right? Which editor is this? That should probably feature in your post title Read full topic
View ArticleClosures and type hints (in VS Code)
VS Code, I kind of expected more people to be familiar with it. Read full topic
View ArticleClosures and type hints (in VS Code)
Which plugin are you using? This sounds like a feature request to them. (At a guess, I’d say it’s probably going to end up on pylance?) Read full topic
View ArticleClosures and type hints (in VS Code)
yellow2 is 100% expected behavior. You are explicitly telling the type checker that this variable can refer to any callable that takes any number of arguments of any type and returns a str. If that...
View ArticleClosures and type hints (in VS Code)
yellow2 is mostly fine in this specific use case, but unfortunately it can’t include the sep argument. For callables as arguments, keyword arguments aren’t all that useful, but for closures they are....
View Article