Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing for MyPy #1822

Closed
rodrigogiraoserrao opened this issue Feb 17, 2023 · 5 comments
Closed

Fix typing for MyPy #1822

rodrigogiraoserrao opened this issue Feb 17, 2023 · 5 comments
Labels
enhancement New feature or request Task

Comments

@rodrigogiraoserrao
Copy link
Contributor

With the API more stable, we should get Textual passing Mypy.

There are currently 148 errors, but many of them have the same root cause.

It may require a few passes to get all of them. Suggest spending a day on fixing typing, and we will review the situation after.

@rodrigogiraoserrao rodrigogiraoserrao self-assigned this Feb 17, 2023
@rodrigogiraoserrao
Copy link
Contributor Author

Follow-up: see if my suggestion in #1813 breaks typing.

@rodrigogiraoserrao rodrigogiraoserrao added enhancement New feature or request Task labels Feb 17, 2023
@rodrigogiraoserrao
Copy link
Contributor Author

Edit: By the time I picked this up, there were 85 errors.

@darrenburns two issues read:

src/textual/_two_way_dict.py:41: error: Incompatible return value type (got "Optional[Value]", expected "Value")  [return-value]
src/textual/_two_way_dict.py:52: error: Incompatible return value type (got "Optional[Key]", expected "Key")  [return-value]

To guide my fix, I need to know if the rationale here is that the methods .get and .get_key never fail?
Or are they supposed to be mirroring dict.get? In which case, we probably need to restore the default: T | None = None annotation and fix typing in the correct way.

@rodrigogiraoserrao
Copy link
Contributor Author

These have been axed down to around 30 in Python 3.7.
Most of them come from the widget Data Table and interactions with the TwoWayDict implemented in _two_way_dict. The PR above contains a possible approach but this needs to be validated with @darrenburns.

@rodrigogiraoserrao rodrigogiraoserrao removed their assignment Mar 6, 2023
@willmcgugan
Copy link
Collaborator

Typing is an ongoing thing. We will have another pass soon.

@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Task
Projects
None yet
Development

No branches or pull requests

2 participants