测试gitnore

This commit is contained in:
ladeng07
2022-05-06 15:45:57 +08:00
parent 12f390949b
commit 51552904f9
2347 changed files with 120102 additions and 53549 deletions
+16 -10
View File
@@ -19,8 +19,7 @@ def _get_callable_parameters(meth_or_func):
def get_func_args(func):
params = _get_callable_parameters(func)
return [
param.name
for param in params
param.name for param in params
if param.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD
]
@@ -36,12 +35,12 @@ def get_func_full_args(func):
for param in params:
name = param.name
# Ignore 'self'
if name == "self":
if name == 'self':
continue
if param.kind == inspect.Parameter.VAR_POSITIONAL:
name = "*" + name
name = '*' + name
elif param.kind == inspect.Parameter.VAR_KEYWORD:
name = "**" + name
name = '**' + name
if param.default != inspect.Parameter.empty:
args.append((name, param.default))
else:
@@ -51,21 +50,28 @@ def get_func_full_args(func):
def func_accepts_kwargs(func):
"""Return True if function 'func' accepts keyword arguments **kwargs."""
return any(p for p in _get_callable_parameters(func) if p.kind == p.VAR_KEYWORD)
return any(
p for p in _get_callable_parameters(func)
if p.kind == p.VAR_KEYWORD
)
def func_accepts_var_args(func):
"""
Return True if function 'func' accepts positional arguments *args.
"""
return any(p for p in _get_callable_parameters(func) if p.kind == p.VAR_POSITIONAL)
return any(
p for p in _get_callable_parameters(func)
if p.kind == p.VAR_POSITIONAL
)
def method_has_no_args(meth):
"""Return True if a method only accepts 'self'."""
count = len(
[p for p in _get_callable_parameters(meth) if p.kind == p.POSITIONAL_OR_KEYWORD]
)
count = len([
p for p in _get_callable_parameters(meth)
if p.kind == p.POSITIONAL_OR_KEYWORD
])
return count == 0 if inspect.ismethod(meth) else count == 1