Is there some way of expressing this Scala code with Python's type hints? trait List[A] { def ::[B >: A](x: B): List[B] } I'm trying to achieve this sort
Consider the following code: from typing import Callable, Any TFunc = Callable[..., Any] def get_authenticated_user(): return "John" def require_auth() ->
I have a function that uses typing.get_type_hints. I want to add a documentation test to it. However, it looks like get_type_hints fails to resolve types that a
I want to type hint the following function: def get_obj_class(self) -> CLASS_TYPE: return self.o.__class__ CLASS_TYPE should denote classes. self.o could
I am trying to silence mypy errors based on error codes. This is done using something like this: from foolib import foo # type: ignore[attr-defined] I beli
how to solve the recursion problem when specifying type hints for classes from different files models1.py from models2 import Second @dataclass class First:
I have a function that looks like this: def check_for_errors(result): if 'success' in result: return True if 'error' in result: raise
I have a function of this form: def foo(o: "hello") -> dict: # pass I understand that the "-> dict" means that foo returns a dictionary. What I don
I have the following code in Python 3: class Position: def __init__(self, x: int, y: int): self.x = x self.y = y def __add__(self, oth
What is the conventional way to express in a docstring the expected types of keyword arguments? Or is this out of principle something I should not be doing at
The following code: class Type { } function foo(Type $t) { } foo(null); failed at run time: PHP Fatal error: Argument 1 passed to foo() must not be null
I'm trying to write a :rtype: type hint for a generator function. What is the type it returns? For example, say I have this functions which yields strings: d