Skip to content

Improve type hints #51

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Rogdham
Copy link

@Rogdham Rogdham commented Jan 15, 2025

I was not sure what the minimal Python version for type hints is supported, so I tried to be the most compatible. However, I believe it still needs Python 3.5 to be able to import Type from typing.

Things that could be simplified/improved:

  • the import of Protocol (Python 3.8)
  • using PEP 570 for the arguments to .read and .write (Python 3.8)
  • using builtin type instead of Type (Python 3.9)
  • importing Callable from collections.abc (Python 3.10)

Things not treated in this PR:

  • simplfying bytes | bytearray to bytes (mypy doc): it does not hurt to keep it this way
  • proper typing of the **options params: it does not bring a lot to type them properly, and it adds maintainability burden (e.g. you would need to modify the type hints each time you add a new param)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant