The information is there; itâs up to whatever tool you are using to make use of it.
(By the way, [2] is not a valid default factory; it needs to be lambda: [2], as the factory needs to be called. I would not expect any tool to report the return value of a default factory as the default value of c.)
Do you have any advice how I can discover why my particular IDE is not making use of the information, or what information it is making use of (so that I can put the information in the correct place for the IDE)?
And: how can I confirm that the information is there, where it is supposed to be?
(Yes, I made a mistake whilst reducing my code to a minimal example. I do use a lambda in the version that Iâm actually using. Oops.)
... appers to simply mean âa default existsâ. Determining what that default is requires some effort, and any effort may be more than what the IDE wants to exert.
0 is pretty simple. 1 + 3 is not quite as simple, but not too bad. pow(3, 2) is getting a little more complicated. field(...) is a conceptual leap: the result of field is not the default, but some value (if any!) produced by the field, which isnât obvious as all. And thatâs just for a function call that you could hard-code logic for, because itâs in the standard library. What about something similar provided by an arbitrary 3rd-party package?
I think itâs reasonable for an editor to not make any assumptions, other than âa default existsâ and represent any and all syntactic defaults with a single ....
That sound like a different answer from what you gave before?
I would be willing to spend a bit of code adding to the metadata, if that meant that I got good type hints for the init. If there was a way to add to the metadata so that both the init and the attribute got the correct type hints, that would be even better.
For example if there is a attribute with the field = field(default_factory=list) I could imagine adding to that
The IDE is not part of the language. Type hints and default values exist for reasons other than for the IDE to provide pop-up hints about how to write code. The effort I am talking about is not programmer effort, but IDE effort to derive static information from what might otherwis be dynamically evaluated code.
An IDE could specify that it would use âextraâ code for its own purposes, but I, as someone who does not use that IDE, would not want to work with code cluttered with hints I have no use for.