PHP 7 introduces return type declarations. Which means I can now indicate the return value is a certain class, interface, array, callable or one of the newly hintable scalar...
I am practicing using type hints in Python 3.5. One of my colleague uses typing.Dict: import typing def change_bandwidths(new_bandwidths: typing.Dict, user_id: int, user_name: str) -> bool: print(new_bandwidths, user_id, user_name)...
In python 3.x, it is common to use return type annotation of a function, such as: def foo() -> str: return "bar" What is the correct annotation for the...
Is there any correct type hint to use for a file or file-like object in Python? For example, how would I type-hint the return value of this function? def...
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...
Here is my code: function phpwtf(string $s) { echo "$s\n"; } phpwtf("Type hinting is da bomb"); Which results in this error: Catchable fatal error: Argument 1 passed to phpwtf()...
Using Python 3’s function annotations, it is possible to specify the type of items contained within a homogeneous list (or other collection) for the purpose of type hinting in...
I’m trying to split my huge class into two; well, basically into the “main” class and a mixin with additional functions, like so: main.py file: import mymixin.py class Main(object,...
How do I use type hints to annotate a function that returns an Iterable that always yields two values: a bool and a str? The hint Tuple[bool, str] is...
Suppose I have a function: def get_some_date(some_argument: int=None) -> %datetime_or_None%: if some_argument is not None and some_argument == 1: return datetime.utcnow() else: return None How do I specify the...