Top "Type-hinting" questions

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

Name not defined in type annotation

I'm currently working on creating a python linear algebra module for fun and for practice with the language. I recently …

python python-3.x type-hinting
How to unit test functions that use type hinting

Lets say I have a class that contains a function that uses type hinting like this: class Testable { function foo (…

unit-testing symfony mocking phpunit type-hinting
Python 3 dictionary with known keys typing

I'm using Python 3 typing feature for better autocomplete. Many times I have functions that return key/value (dictionary) with specific …

python python-3.x dictionary type-hinting
Need type annotation for variable in python 3.5 code

I am using mypy on my python 3.5 code, and I got a lot of messages which look like this: file:…

python python-3.x type-hinting mypy
Python type hints: typing.Mapping vs. typing.Dict

I'm working on a python3 project where we use the typing module type hints throughout. It seems that we use …

python python-3.x type-hinting
How do I specify multiple types for a parameter using type-hints?

I have a Python function which accepts XML data as an str. For convenience, the function also checks for xml.…

python python-3.x arguments type-hinting
How do you alias a type in Python?

In some (mostly functional) languages you can do something like this: type row = list(datum) or type row = [datum] So …

python alias type-hinting python-typing
How to type hint a generic numeric type in Python?

Forgive me if this question has been asked before but I could not find any related answer. Consider a function …

python python-3.x types type-hinting
Specify length of Sequence or List with Python typing module

I'm giving the Python typing module a shot. I know that it's valid to specify the length of a List …

python python-3.x type-hinting mypy
How to type hint a dictionary with values of different types

When declaring a dictionary as a literal, is there a way to type-hint what value I am expecting for a …

python dictionary pycharm type-hinting typing