peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Apache License 2.0
3.62k stars 237 forks source link

Provide library stubs (type hinting) for compatibility with Mypy (e.g.: typeshed) #240

Open Maroloccio opened 4 years ago

Maroloccio commented 4 years ago

At the moment the lack of type hinting requires turning off mypy checks. It would be helpful to offer library stubs.

peterbrittain commented 4 years ago

Looks like a good idea... Anyone willing to help out here?

JPTIZ commented 3 years ago

Is it just set typehints to the whole code? I can do it if it is the issue.

EDIT: ok, I went to check mypy errors and I think I got the real issue:

asciimatics/paths.py:9: error: Skipping analyzing 'future.utils': found module but no type hints or library stubs                                                                                                                              
asciimatics/paths.py:32: error: Unsupported dynamic base class "with_metaclass"                                                                                                                                                                
asciimatics/paths.py:187: error: Unsupported dynamic base class "with_metaclass" 

Unfotunately, for this one, it is not possible to install future-stubs because it depends on python-future, which does not exist anymore (apparently it was renamed to simply future).

A lot of mypy errors are from Py2 compatibility code. Since there's no more official support to Py2 since the beginning of this year, what if asciimatics dropped support to it, sticking only with Py3?

EDIT2: Ok, maybe dropping support just because typehinting is not working as expected seems overkill.

But updates: I'm getting there, I am! Found this and now the issue makes 100% sense to me: https://mypy.readthedocs.io/en/stable/stubs.html

peterbrittain commented 3 years ago

As I understand it, that is just an error saying that the stubs for futufe are missing and I'm not convinced that future-stubs is maintained from the fact it can't be installed.

Did you try any of the workarounds here (https://mypy.readthedocs.io/en/stable/running_mypy.html) - e.g. generating your own future stub files with stubgen?

JPTIZ commented 3 years ago

As I understand it, that is just an error saying that the stubs for futufe are missing and I'm not convinced that future-stubs is maintained from the fact it can't be installed.

Did you try any of the workarounds here (https://mypy.readthedocs.io/en/stable/running_mypy.html) - e.g. generating your own future stub files with stubgen?

It did work :) Submitted my current WIP