-
Notifications
You must be signed in to change notification settings - Fork 128
Description
Now that cmd2 no longer needs to support Python 2.7 from release 0.9.0 onward, we can begin to add type hinting to function/method arguments and return values.
Everyone is encouraged to begin doing this for all new and modified code. In the long run it should make the code easier to read and maintain.
Note: If you use type hinting for function/method arguments and/or return values, then just use type hinting. Don't put the type in a docstring comment if you are using type hinting. With tools like the mypy static analysis type checker and PyCharm, it is much easier to ensure that Python 3 optional type hints stay in sync with actual code changes. It is much more likely that the documentation comments could get out of sync.
If you modify an existing function/method to add type hinting and it previously had type info in the docstring, then please remove the type info from the docstring.
Please do NOT start adding type hinting to local variables as support for this syntax wasn't added until Python 3.6.
Also, for now please be careful to use types from the typing module which exist in Python 3.5 and the typing module backport for Python 3.4 - a lot of additional types were added to that module in Python 3.6.