loosing vscode syntax highlighting on a certain object using "alive_it" function
BUZZARDGTA opened this issue · 2 comments
BUZZARDGTA commented
I've got an issue where "thread" loose it's vscode syntax highlighting.
Here is my code, and my Python version, if needed: Python 3.11.2
from typing import List
threads: List[threading.Thread] = []
for thread in alive_it(threads, theme="classic", bar="classic2", enrich_print=False):
thread.join()
vscode result:
rsalmei commented
Hello again.
You're right, I do not annotate alive_it
at all, and I really should.
But I'm not an expert in typing, would you know how to express this kind of "generics" in Python, I mean, a function that receives a List[T]
, and yields exactly those T
whatever they are?
rsalmei commented
I think I got it. With this, your example does get the correct type.
T = TypeVar('T')
def alive_it(it: Collection[T], total: Optional[int] = None, *,
finalize: Callable[[Any], None] = None,
calibrate: Optional[int] = None, **options: Any) -> Iterable[T]: