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

Improve Doc.get return value type #80

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

davidbrochart
Copy link
Collaborator

With this change, mypy knows the return type of Doc.get("foo", type=MyType) is MyType, while it was previously BaseType. The type passed to type must still be a BaseType.
This can be seen by running mypy test.py:

# test.py
from pycrdt import Doc, Text

doc = Doc()
text = doc.get("text", type=Text)
print(reveal_type(text))
# note: Revealed type is "pycrdt._text.Text"
doc.get("foo", type=int)
# error: Value of type variable "T_BaseType" of "get" of "Doc" cannot be "int"  [type-var]

@davidbrochart davidbrochart merged commit fb6caf2 into jupyter-server:main Feb 15, 2024
16 checks passed
@davidbrochart davidbrochart deleted the ydoc-get branch February 15, 2024 11:27
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