Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jan 31, 2023

Following a9c62c5, stubtest now verifies parameter defaults in a stub (when they're present). However, if a global or class variable in a stub has a default value, stubtest currently does no verification of the value (only the type).

Unfortunately, it seems like mypy does not store the value for most variable assignments, so it is hard to verify the value. However, it does store the value for Final variables.

@AlexWaygood AlexWaygood marked this pull request as draft February 1, 2023 00:27
@AlexWaygood AlexWaygood marked this pull request as ready for review February 2, 2023 17:39
if fallback.fullname == "builtins.str":
stub_value = node_for_stub_value.value
elif fallback.fullname == "builtins.bytes":
stub_value = bytes(node_for_stub_value.value, "utf-8")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about these codecs to decide whether this is an actual problem, but FWIW mypyc converts BytesExpr.value into bytes in a bit more involved way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants