Skip to content

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