sh icon indicating copy to clipboard operation
sh copied to clipboard

Type Annotations

Open remexre opened this issue 3 years ago • 4 comments

It'd be nice if this package shipped mypy type annotations.

remexre avatar Aug 12 '21 03:08 remexre

That would have to wait for removal of Python 2 support. We're tracking various improvements suggested for a 2.0 release in https://github.com/amoffat/sh/issues/552, among them dropping support for Python 2.

ecederstrand avatar Aug 12 '21 19:08 ecederstrand

Are there specific type annotations you are looking for @remexre ?

amoffat avatar Sep 04 '21 16:09 amoffat

Not any specific thing, I just get errors from mypy about it not having type annotations.

remexre avatar Sep 04 '21 16:09 remexre

Ok, I will run mypy on sh.py and take care of the findings. It looks like there are only 5 on the release/v2.0.0 branch:

(sh-chCS6MrZ-py3.8) ➜  sh git:(feature/v2.0.0) ✗ mypy sh.py
sh.py:196: error: Name "Poller" already defined on line 118
sh.py:379: error: Need type annotation for "rc_exc_cache" (hint: "rc_exc_cache: Dict[<type>, <type>] = ...")
sh.py:472: error: Incompatible types in assignment (expression has type "Callable[[Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[AnyStr, DefaultNamedArg(bool, 'recursive')], List[AnyStr]]")
sh.py:891: error: Incompatible types in assignment (expression has type "None", base class "object" defined the type as "Callable[[object], int]")
sh.py:1109: error: Need type annotation for "_call_args"
Found 5 errors in 1 file (checked 1 source file)

amoffat avatar Sep 04 '21 16:09 amoffat

Python 2.0 support is now removed in 2.0.0, and mypy sh.py is clean

amoffat avatar Feb 09 '23 20:02 amoffat