Skip to content
Discussion options

You must be logged in to vote

Hey! I'm doing this in a project of mine wrapping Google Benchmark. The fix for you should be as simple as return ctx; in the body of __enter__ as you suspected, check this for reference: https://github.com/nicholasjng/mew/blob/d5d2790a8f18b019195bc263da0e807d481e52f6/src/_mew/state.cpp#L49-L63

The nb::sig() annotation there is useful because it follows Python's context manager protocol exactly and outputs a neatly annotated stub that doesn't trip type checkers, but it might be overkill for your purposes.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by patrickd-galil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants