This suggested edit fixes a genuine bug in my opinion, but it was rejected. I am the author of the original answer, and the commenter (xoolive) picked a bug in the code. I suggested to him in a comment to the answer that his comment is correct and that he should edit the answer to fix it.
Later I see that the edit was rejected with the comment "deviates from the original intent". I can't see why using the inspect
module in a couple of lines would deviate from the original intent.
Can you please reconsider?
Specifically, in Python code when more than one parameter has the same type there are no guarantees that the dictionary __annotations__
will be able to distinguish between the parameters given that the order is not preserved and the keys of the dict in the original code are lost.