progress icon indicating copy to clipboard operation
progress copied to clipboard

Type hints!!!

Open ThatXliner opened this issue 5 years ago • 6 comments

https://kishstats.com/python/2019/01/07/python-type-hinting.html

https://docs.python.org/3/library/typing.html

ThatXliner avatar Jan 07 '21 04:01 ThatXliner

$ mypy --install-types --non-interactive .

progress/setup.py:3: error: Skipping analyzing "setuptools": found module but no type hints or library stubs
progress/setup.py:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
progress/progress/spinner.py:34: error: Incompatible types in assignment (expression has type "List[str]", base class "Spinner" defined the type as "Tuple[str, str, str, str]")
progress/progress/spinner.py:38: error: Incompatible types in assignment (expression has type "List[str]", base class "Spinner" defined the type as "Tuple[str, str, str, str]")
progress/progress/spinner.py:42: error: Incompatible types in assignment (expression has type "List[str]", base class "Spinner" defined the type as "Tuple[str, str, str, str]")
progress/progress/spinner.py:46: error: Incompatible types in assignment (expression has type "List[str]", base class "Spinner" defined the type as "Tuple[str, str, str, str]")
progress/progress/counter.py:48: error: Incompatible types in assignment (expression has type "Tuple[str, str, str, str, str]", base class "Stack" defined the type as "Tuple[str, str, str, str, str, str, str, str, str]")
progress/progress/bar.py:89: error: Incompatible types in assignment (expression has type "Tuple[str, str, str, str, str, str, str, str]", base class "IncrementalBar" defined the type as "Tuple[str, str, str, str, str, str, str, str, str]")
progress/progress/bar.py:93: error: Incompatible types in assignment (expression has type "Tuple[str, str, str, str, str]", base class "IncrementalBar" defined the type as "Tuple[str, str, str, str, str, str, str, str, str]")
Found 8 errors in 4 files (checked 7 source files)

cclauss avatar Aug 02 '21 10:08 cclauss

I can implement type hints. Will begin work later tonight and send a PR when ready

PaulConwayiii avatar Jun 27 '22 17:06 PaulConwayiii

AFAIK there is no way to implement type hints throughout the entire project and still maintain Python 2.6+ compatibility. The issue comes down to having non-literal types (lists, tuples). There is probably a way to make it work, but not cleanly. I also had not realized that when I made my PR that the typing module was introduced in Python 3.5, so that would break compatibility for older Python 3 versions if used. Since Python 2.6+ compatibility is required currently, I say we close this issue until an explicit decision is made by verigak to ditch older Python versions

PaulConwayiii avatar Jul 11 '22 15:07 PaulConwayiii

Python 2 died 922 days ago on 1/1/2020 so I think it is time to move on... So we can show some progress.

cclauss avatar Jul 11 '22 15:07 cclauss

You can also provide type hints in .pyi stub files. Older versions of python just won't read them.

normanr avatar Jan 05 '24 09:01 normanr

The project’s name is progress so let’s make some progress by dropping all CPython versions that are no longer supported. Python 2 died 1,465 days ago on 1/1/2020. https://devguide.python.org/versions

cclauss avatar Jan 05 '24 11:01 cclauss