werkzeug icon indicating copy to clipboard operation
werkzeug copied to clipboard

TypeConversionDict.pop with type

Open lczyk opened this issue 1 year ago • 3 comments

Proposed implementation of pop with type parameter on TypeConversionDict. Address #2883.

lczyk avatar Apr 26 '24 16:04 lczyk

Typing is slightly messy, but I think correct. mypy certainly seems to be happy with it. I've had to battle a bit with ImmutableTypeConversionDict typing, but won in the end.

lczyk avatar Apr 26 '24 16:04 lczyk

@davidism anything else which needs to happen here? (all good if just waiting / no-one gotten to it. just wanna make sure i'm not sitting idle on something i'm supposed to be doing here)

lczyk avatar Jun 21 '24 16:06 lczyk

Since I often use this in a non-werkzeug context, I've extracted the TypeConversionDict into a single-file micro-package: https://github.com/MarcinKonowalczyk/type_conversion_dict.

I thought it relevant to post here since i've done quite a bit of test + typing work there. The get and pop signatures are compatible with dict and werzeug.datastructures.TypeConversionDict.

In that implementation i've also added a required kwarg which I find very useful but i don't propose to add it here ( at least not in this PR/Issue. Obv feel free to add it too if you like it :)) )

lczyk avatar Jun 23 '24 23:06 lczyk