The SC is happy to say that we accept the PEP (w/ the syntax changes removed)!
And to reiterate, the SC is not wholly against the syntax change, but we do feel it deserves a separate PEP for a more thorough discussion.
The SC is happy to say that we accept the PEP (w/ the syntax changes removed)!
And to reiterate, the SC is not wholly against the syntax change, but we do feel it deserves a separate PEP for a more thorough discussion.
The PEP mentions
Also, for the benefit of IDEs and documentation pages, functions that are part of the public API should prefer explicit keyword parameters whenever possible.
To me this indeed seems like a good reason to still prefer duplication over using this new feature. But I wonder if maybe IDEs/LSPs will be able to do the unpacking for the user, i.e. show the TypedDict fields as normal keyword parameters (completely hiding the use of **kwargs
), and auto-complete the parameters.
@erictraut (hope you donāt mind my question), do you think this will be possible to do in the Pylance LSP, or is there something preventing it?
The current implementation in Pylance does not show the TypedDict fields as normal keyword parameters, nor does it auto-complete the parameters if PEP 692 is used. These are both theoretically possible to do and (IMO) worth considering. User feedback plays heavily into decisions made by the Pylance team, so if this is something youād like to see, I encourage you to submit an enhancement request in the pylance-release issue tracker.
Iām not aware of any library using this feature yet, so no need from me, but itās good to know that itās possible, thanks.
One thing that will definitely be lost is seeing the value of the parameter defaults in the hover/documentation, so NotRequired
fields will need to be shown as param=...
instead of param=100
, I donāt think thereās a way around that.