Use generic arg names for functions without explicitly named arguments

Example signatures (old => new):
  foo(int) => foo(arg0: int)
  bar(Object, int) => bar(self: Object, arg0: int)

The change makes the signatures uniform for named and unnamed arguments
and it helps static analysis tools reconstruct function signatures from
docstrings.

This also tweaks the signature whitespace style to better conform to
PEP 8 for annotations and default arguments:
  " : " => ": "
  " = " => "="
This commit is contained in:
Dean Moldovan
2016-07-31 20:03:18 +02:00
parent 52d77d9db9
commit ecced6c5ae
6 changed files with 71 additions and 28 deletions

View File

@@ -1,32 +1,52 @@
Help on built-in function kw_func in module example
Help on built-in function kw_func0 in module example
kkww__ffuunncc(...)
kw_func(x : int, y : int) -> NoneType
kkww__ffuunncc00(...)
kw_func0(arg0: int, arg1: int) -> NoneType
Help on built-in function kw_func1 in module example
kkww__ffuunncc11(...)
kw_func1(x: int, y: int) -> NoneType
Help on built-in function kw_func2 in module example
kkww__ffuunncc22(...)
kw_func2(x : int = 100L, y : int = 200L) -> NoneType
kw_func2(x: int=100L, y: int=200L) -> NoneType
Help on built-in function kw_func3 in module example
kkww__ffuunncc33(...)
kw_func3(data : unicode = u'Hello world!') -> NoneType
kw_func3(data: unicode=u'Hello world!') -> NoneType
Help on built-in function kw_func4 in module example
kkww__ffuunncc44(...)
kw_func4(myList : list<int> = [13L, 17L]) -> NoneType
kw_func4(myList: list<int>=[13L, 17L]) -> NoneType
Help on built-in function kw_func_udl in module example
kkww__ffuunncc__uuddll(...)
kw_func_udl(x : int, y : int = 300L) -> NoneType
kw_func_udl(x: int, y: int=300L) -> NoneType
Help on built-in function kw_func_udl_z in module example
kkww__ffuunncc__uuddll__zz(...)
kw_func_udl_z(x : int, y : int = 0L) -> NoneType
kw_func_udl_z(x: int, y: int=0L) -> NoneType
Help on built-in function args_function in module example
aarrggss__ffuunnccttiioonn(...)
args_function(*args) -> NoneType
Help on built-in function args_kwargs_function in module example
aarrggss__kkwwaarrggss__ffuunnccttiioonn(...)
args_kwargs_function(*args, **kwargs) -> NoneType
foo0(self: KWClass, arg0: int, arg1: float) -> NoneType
foo1(self: KWClass, x: int, y: float) -> NoneType
kw_func(x=5, y=10)
kw_func(x=5, y=10)
@@ -38,7 +58,7 @@ kw_func(x=100, y=10)
kw_func(x=5, y=10)
kw_func(x=5, y=10)
Caught expected exception: Incompatible function arguments. The following argument types are supported:
1. (x : int = 100L, y : int = 200L) -> NoneType
1. (x: int=100L, y: int=200L) -> NoneType
Invoked with:
kw_func4: 13 17
kw_func4: 1 2 3