5/16/2023 0 Comments Value with keyclickThat explains why the mechanism described in PEP 692 is a latecomer to the type system compared to other well-established facilities like specification of positional-only parameters, keyword-only parameters, and overloads. Note that most functions written in Python, even if they use **kwargs in their implementation, do not follow this design pattern. Here's another discussion in the mypy issue tracker that provides some examples where it might be useful. PEP 692 is useful in cases where an API accommodates optional keyword-only parameters when no default values are provided for absent keywords. It is not a replacement for the existing, well-established mechanisms in the type system for describing function signatures with keyword parameters. The facility described in PEP 692 has utility, but it is applicable only for certain use cases. In fact, I implemented support for the mechanism in pyright when Franek was working on the initial draft of the PEP. On the contrary, I'm supportive of PEP 692. I’m inclined to believe you are against PEP 692 In all cases, it would seem better to simply type out the information rather than hide it behind a TypedDict.īeta Was this translation helpful? Give feedback. To that end, I will recommend an additional note be added to the PEP that recommends against its usage wherever possible as it tends to abstract away useful type hinting information rather than add to it. It should be up to the purview of the coder to choose whether or not to use it. Ultimately, I see now that PEP 692 is a convenience rather than a necessity. This in turn prevents the project from getting all of the benefits that type hinting can provide.Įven though you showed the additional type hinting is a rather less than useful Ironically, part of its motivation states it is useful for:Įxisting codebases where the need of refactoring the code in order to introduce proper type annotations may be considered not worth the effort. Thank you again for your help (and Happy Father's Day as well).įrom our conversation, I’m inclined to believe you are against PEP 692, and I understand why.
0 Comments
Leave a Reply. |