Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@laomaiweng
Copy link

The default implementation of Construct.sizeof unconditionally raises a SizeofError, because it is meant to be overridden in subclasses. This confuses some type checkers (e.g., pyright) which incorrectly (from construct's point-of-view) infer Construct.sizeof to not return, assigning it the NoReturn return type.

Explicitly set the return type hint for Construct.sizeof to int, so that pyright correctly deals with this function.

The default implementation of `Construct.sizeof` unconditionally raises a `SizeofError`, because it is meant to be overridden in subclasses. This confuses some type checkers (e.g., pyright) which incorrectly infer `Construct.sizeof` to not return (assigning the `NoReturn` return type).

Explicitly set the return type hint for `Construct.sizeof` to `int`, so that pyright correctly deals with this function.
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.