classification
Title: inspect.Signature.parameters should be an OrderedDict, not a plain dict
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: methane Nosy List: donovick, methane
Priority: normal Keywords: patch

Created on 2020-02-27 13:47 by Antony.Lee, last changed 2020-03-02 11:09 by Antony.Lee. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18684 merged methane, 2020-02-28 07:49
Messages (4)
msg362800 - (view) Author: Antony Lee (Antony.Lee) * Date: 2020-02-27 13:47
https://bugs.python.org/issue36350 / https://github.com/python/cpython/pull/12412 changed Signature.parameters and BoundArguments.arguments to be plain dicts, not OrderedDicts (for Py3.9a4).  Even though I agree for BoundArguments.arguments (in fact I argued for this behavior in https://bugs.python.org/issue23080), I think Signature.parameters should remain OrderedDicts.  Otherwise, one would get

    >>> inspect.signature(lambda x, y: None).parameters == inspect.signature(lambda y, x: None).parameters
    True

which seems plain wrong (comparing the signature objects themselves still correctly return False because __eq__ explicitly considers parameter order, but one may e.g. want to compare parameters for equality while ignoring the return annotation).
msg362870 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-02-28 07:54
Would you review the PR 18684?
msg362871 - (view) Author: Antony Lee (Antony.Lee) * Date: 2020-02-28 09:16
It looks good to me, thanks.
msg363147 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-03-02 09:54
New changeset 211055176157545ce98e6c02b09d624719e6dd30 by Inada Naoki in branch 'master':
bpo-39775: inspect: Change Signature.parameters back to OrderedDict. (GH-18684)
https://github.com/python/cpython/commit/211055176157545ce98e6c02b09d624719e6dd30
History
Date User Action Args
2020-03-02 11:09:55Antony.Leesetnosy: - Antony.Lee
2020-03-02 09:55:04methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-03-02 09:54:52methanesetmessages: + msg363147
2020-02-28 09:16:00Antony.Leesetmessages: + msg362871
2020-02-28 07:54:20methanesetmessages: + msg362870
2020-02-28 07:49:44methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request18044
2020-02-28 06:42:12rhettingersetassignee: methane
2020-02-28 05:31:48methanesetnosy: + methane
2020-02-28 02:28:58donovicksetnosy: + donovick
2020-02-27 13:47:39Antony.Leecreate