Fixed callable inspection for return values of getattr() (PY-7625)

This commit is contained in:
Andrey Vlasovskikh
2013-01-29 18:35:21 +04:00
parent c25125bd7b
commit 8ac22cc853
4 changed files with 22 additions and 9 deletions
+4 -4
View File
@@ -62,7 +62,7 @@ __builtin__.filter.3 = \
__builtin__.getattr = \
:type name: string \n\
:rtype: unknown \n\
:rtype: object or unknown \n\
__builtin__.globals = \
:rtype: dict of (bytes, object)
@@ -129,7 +129,7 @@ __builtin__.reduce = \
:type function: collections.Callable \n\
:type sequence: collections.Iterable \n\
:type initial: object or None \n\
:rtype: unknown \n\
:rtype: object or unknown \n\
__builtin__.round = \
:type number: int or long or float \n\
@@ -1073,7 +1073,7 @@ __builtin__.tuple.__rmul__ = \
__builtin__.tuple.__getitem__ = \
:type y: int \n\
:rtype: unknown \n\
:rtype: object or unknown \n\
## 5.8 Mapping types
@@ -2877,7 +2877,7 @@ subprocess.Popen.send_signal = \
json.loads = \
:type s: string \n\
:type encoding: string \n\
:rtype: unknown \n\
:rtype: object or unknown \n\
## 18.12. base64
@@ -438,16 +438,17 @@ public class PyTypeChecker {
}
}
else if (type instanceof PyUnionType) {
Boolean result = true;
for (PyType member : ((PyUnionType)type).getMembers()) {
final Boolean result = isCallable(member);
if (result == null) {
final Boolean callable = isCallable(member);
if (callable == null) {
return null;
}
else if (!result) {
return false;
else if (!callable) {
result = false;
}
}
return true;
return result;
}
else if (type instanceof PyCallableType) {
return true;
@@ -0,0 +1,7 @@
class value():
pass
class MyClass(object):
def bar(self):
foo = getattr(self, 'foo')
foo()
@@ -64,6 +64,11 @@ public class PyCallingNonCallableInspectionTest extends PyTestCase {
doTest();
}
// PY-8182
public void testGetattrCallable() {
doTest();
}
private void doTest() {
setLanguageLevel(LanguageLevel.PYTHON27);
try {