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

update signatures and annotations #400

Merged
merged 5 commits into from
Sep 15, 2023
Merged

update signatures and annotations #400

merged 5 commits into from
Sep 15, 2023

Conversation

davidism
Copy link
Member

  • Use deferred evaluation of annotations (from __future__ import annotations).
  • Implement str methods directly, instead of using wrapper functions. The primary reason was to make pyright understand the types for each method. But this should also result in some amount of speedup, since the wrapper does not need to run at import, and methods can escape their exact arguments directly rather than incurring two function calls and multiple isinstance checks.
  • Use positional-only arguments, and refactor argument names. For str methods, this makes the signatures match those reported by python -m pydoc str. Also added to local functions and methods, such as escape(s, /), to better match the str signatures.
  • Add type annotations to tests.
  • Check types with pyright, both pyright and pyright --verifytypes pass.

wrapper wasn't accurate with types, required extra calls and instance checks
update str method signatures to match Python 3.8
@davidism davidism added this to the 2.2.0 milestone Sep 15, 2023
@davidism davidism merged commit 6e353f9 into main Sep 15, 2023
11 checks passed
@davidism davidism deleted the typing branch September 15, 2023 14:47
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant