Skip to content

Change event typing, and other fixes#4663

Open
Liam-DeVoe wants to merge 11 commits intoHypothesisWorks:masterfrom
Liam-DeVoe:next
Open

Change event typing, and other fixes#4663
Liam-DeVoe wants to merge 11 commits intoHypothesisWorks:masterfrom
Liam-DeVoe:next

Conversation

@Liam-DeVoe
Copy link
Member

@Liam-DeVoe Liam-DeVoe commented Feb 16, 2026

  • event(value, payload) accepts any string-coercible value in payload, and the type hint of Any now reflects this.
  • Following Handle unhashable modules in constants collection #4661, modules are now tracked by id instead of hash, which is equivalent for ModuleType and cleaner otherwise.

b33e473 is the result of FORMAT_ALL=true ./build.sh format. It's a bug that we didn't format all files at tool bump, but I don't have a root cause narrowed down.

@Liam-DeVoe Liam-DeVoe requested a review from Zac-HD as a code owner February 16, 2026 16:17
@Liam-DeVoe Liam-DeVoe changed the title Remove lstar, change event typing Change event typing, and other fixes Feb 16, 2026
Comment on lines -273 to +283
def event(value: str, payload: str | int | float = "") -> None:
def event(value: str, payload: Any = "") -> None:
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a case where I actually prefer our type annotations to be stricter than the runtime logic - while more exotic payloads 'mostly work', it'd be nice to keep weird problems with string conversion as the user's problem.

For the same usage-hint reason that we say value: str, let's keep payload: str | int | float.

Copy link
Member Author

Choose a reason for hiding this comment

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

I disagree with this. My interpretation of your position: type hints have two purposes; documentation, and correctness. We type payload: str | int | float to communicate "these are the normal types you'll be passing" to a user seeing event for the first time. But this comes at the expense of requiring other users to add type: ignore at their usage sites. Since we explicitly document that string-convertible objects are valid, I think the types should reflect this.

What about payload: SupportsStr, which is a typing protocol that requires __str__? I hadn't realized we do the same conversion for value, so I'd also support value: SupportsStr.

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.

2 participants