Top "Type-hinting" questions

Type hinting binds function arguments to specific objects or strongly types them.

typing.Any vs object?

Is there any difference between using typing.Any as opposed to object in typing? For example: def get_item(L: …

python python-3.5 type-hinting
Type hints: solve circular dependency

The following produces NameError: name 'Client' is not defined. How can I solve it? class Server(): def register_client(self, …

python type-hinting python-3.5
Python 3 type hinting for decorator

Considere the following code: from typing import Callable, Any TFunc = Callable[..., Any] def get_authenticated_user(): return "John" def require_…

python python-3.x decorator type-hinting typing
PHP type-hinting traits

I have a trait. For the sake of creativity, let's call this trait Trait: trait Trait{ static function treat($instance){ // …

php traits type-hinting
Typescript: declare that ALL properties on an object must be of the same type

In Typescript you can declare that all elements in an array are of the same type like this: const theArray: …

typescript types interface type-hinting type-safety
Defining a recursive type hint in Python?

Let's say I have a function that accepts a Garthok, an Iterable[Garthok], an Iterable[Iterable[Garthok]], etc. def narfle_…

python type-hinting python-typing
How to annotate a type that's a class object (instead of a class instance)?

What is the proper way to annotate a function argument that expects a class object instead of an instance of …

python annotations type-hinting
Type hint for NumPy ndarray dtype?

I would like a function to include a type hint for NumPy ndarray's alongside with its dtype. With lists, for …

python numpy python-3.6 type-hinting
How to annotate function that takes a tuple of variable length? (variadic tuple type annotation)

I have a function that takes a tuple of different lengths as an argument: from typing import Tuple def process_…

python python-3.x type-hinting mypy
How to use reveal_type in mypy

I have read that I can reveal the type of variables by using a function called reveal_type, but I …

python type-hinting mypy