-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add basic stub file for native_internal #19988
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
Conversation
|
Hm, just to understand: why exactly this is needed? We already have stubs here https://github.com/python/mypy/blob/master/mypy/typeshed/stubs/mypy-native/native_internal.pyi (similar to Btw looking at this we should change the distribution name to |
| def read_float(data: Buffer, /) -> float: ... | ||
| def write_int(data: Buffer, value: int, /) -> None: ... | ||
| def read_int(data: Buffer, /): ... | ||
| def write_tag(data: Buffer, value: int, /) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be mypy_extensions.u8, not int.
| def __init__(self, source: bytes | None = None, /) -> None: ... | ||
| def getvalue(self) -> bytes: ... | ||
|
|
||
| def write_bool(data: Buffer, value: bool, /) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the read/write functions actually support calling with keywords, e.g. write_int(data=Buffer(), value=42) is valid.
| @@ -0,0 +1,14 @@ | |||
| class Buffer: | |||
| def __init__(self, source: bytes | None = None, /) -> None: ... | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried and explicit None fails with TypeError, also it looks like this one also supports call with keyword. So my original stubs are correct :-)
Tbh I missed that completely. I just saw the editor highlighting / missing autocompletion (in VS Code) and couldn't didn't see the stubs file 😅
Guess that would also one of the main benefits of including the stubs in the librt distribution. Not sure if that magic in the modulefinder would still work then though, so going to close this one. --
Yeah. I just figured it might make sense to enforce only positional attributes via the stubs :) |

No description provided.