mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed false positive for arguments passed to class method without explicit 'self' (PY-6108)
This commit is contained in:
@@ -235,7 +235,18 @@ public class PyCallExpressionHelper {
|
||||
boolean isByClass
|
||||
) {
|
||||
int implicit_offset = 0;
|
||||
if (isByInstance || isConstructorCall) implicit_offset += 1;
|
||||
boolean firstIsArgsOrKwargs = false;
|
||||
final PyParameter[] parameters = callable.getParameterList().getParameters();
|
||||
if (parameters.length > 0) {
|
||||
final PyParameter first = parameters[0];
|
||||
final PyNamedParameter named = first.getAsNamed();
|
||||
if (named != null && (named.isPositionalContainer() || named.isKeywordContainer())) {
|
||||
firstIsArgsOrKwargs = true;
|
||||
}
|
||||
}
|
||||
if (!firstIsArgsOrKwargs && (isByInstance || isConstructorCall)) {
|
||||
implicit_offset += 1;
|
||||
}
|
||||
PyFunction method = callable.asMethod();
|
||||
if (method == null) return implicit_offset;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ def test_union_type():
|
||||
bar = (1,) if True else (1, 2)
|
||||
foo(*bar) #pass
|
||||
|
||||
|
||||
# PY-4890
|
||||
def test_old_style_iterable():
|
||||
class C:
|
||||
@@ -22,4 +23,13 @@ def test_old_style_iterable():
|
||||
pass
|
||||
xs = C()
|
||||
foo(*xs) #pass
|
||||
foo(*'bar') #pass
|
||||
foo(*'bar') #pass
|
||||
|
||||
|
||||
# PY-6108
|
||||
def test_unexpected_args_without_self():
|
||||
class C:
|
||||
def sm(*args, **kwargs):
|
||||
return args, kwargs
|
||||
x = C()
|
||||
x.sm(1, 2, 3) #pass
|
||||
|
||||
Reference in New Issue
Block a user