Issues with inspect.Parameter

The docstring of inspect.Parameter indicates the "default" and "annotation" attributes are not set if the parameter does not have, respectively, a default value and an annotation, and that the "kind" attribute is a string. But in fact, the "default" and "annotation" attributes are set to "inspect._empty (== Parameter.empty)" in that case, and the "kind" attribute has type "_ParameterKind" (essentially a hand-written equivalent of IntEnum). I suggest to correct the docstring accordingly, and to replace the implementation of _ParameterKind by a proper IntEnum (if full backwards compatibility is required), or even just by Enum (which makes a bit more sense, as the fact that _ParameterKind is a subclass of int doesn't seem to be documented anywhere). Antony

I have a (fairly trivial...) patch to fix both of these issues. Should I post it here or submit it to bugs.python.org? Antony
2013/11/10 Antony Lee antony.lee@berkeley.edu
The docstring of inspect.Parameter indicates the "default" and "annotation" attributes are not set if the parameter does not have, respectively, a default value and an annotation, and that the "kind" attribute is a string. But in fact, the "default" and "annotation" attributes are set to "inspect._empty (== Parameter.empty)" in that case, and the "kind" attribute has type "_ParameterKind" (essentially a hand-written equivalent of IntEnum). I suggest to correct the docstring accordingly, and to replace the implementation of _ParameterKind by a proper IntEnum (if full backwards compatibility is required), or even just by Enum (which makes a bit more sense, as the fact that _ParameterKind is a subclass of int doesn't seem to be documented anywhere). Antony

Here we go: http://bugs.python.org/issue19573
2013/11/12 Antony Lee antony.lee@berkeley.edu
I have a (fairly trivial...) patch to fix both of these issues. Should I post it here or submit it to bugs.python.org? Antony
2013/11/10 Antony Lee antony.lee@berkeley.edu
The docstring of inspect.Parameter indicates the "default" and "annotation" attributes are not set if the parameter does not have, respectively, a default value and an annotation, and that the "kind" attribute is a string. But in fact, the "default" and "annotation" attributes are set to "inspect._empty (== Parameter.empty)" in that case, and the "kind" attribute has type "_ParameterKind" (essentially a hand-written equivalent of IntEnum). I suggest to correct the docstring accordingly, and to replace the implementation of _ParameterKind by a proper IntEnum (if full backwards compatibility is required), or even just by Enum (which makes a bit more sense, as the fact that _ParameterKind is a subclass of int doesn't seem to be documented anywhere). Antony
participants (2)
-
Antony Lee
-
Ethan Furman