-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Labels
Milestone
Description
Python 3 supports type hints for parameters and return values.
They make the code a lot more understandable.
E.g.
def modify_env(old: Dict[str, str], new: Dict[str, str], verbose: bool=True) -> None:
def setvar(key: str, value: str, verbose: bool=True) -> None:
def remove_unwanted_chars(inputstring: str) -> str:
With this you can often skip reading the doc string as the semantic is more clear.
Python 3.9 introduces direct support for indexing types, i.e. dict[str, str] or tuple(str, int, int) but for earlier version you got from typing import Dict, Tuple with the same semantic & syntax just using the uppercase letter
I propose gradually introducing such type hints