mirror of
https://github.com/davidhalter/jedi.git
synced 2026-10-20 06:47:05 +08:00
Static analysis tests for type errors with variables.
This commit is contained in:
1 parent
64fcbbba79
commit
5d9fff50af
2 files changed
+22
-3
No files matched your search
@@ -4,8 +4,22 @@ if random.choice([0, 1]):
|
|||||||
x = ''
|
x = ''
|
||||||
else:
|
else:
|
||||||
x = 1
|
x = 1
|
||||||
|
if random.choice([0, 1]):
|
||||||
if x != 1:
|
y = ''
|
||||||
x = x.upper()
|
|
||||||
else:
|
else:
|
||||||
|
y = 1
|
||||||
|
|
||||||
|
# A simple test
|
||||||
|
if x != 1:
|
||||||
|
x.upper()
|
||||||
|
else:
|
||||||
|
#! 2 attribute-error
|
||||||
|
x.upper()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# This operation is wrong, because the types could be different.
|
||||||
|
#! 6 type-error-operation
|
||||||
|
z = x + y
|
||||||
|
# However, here we have correct types.
|
||||||
|
if type(x) == type(y):
|
||||||
|
z = x + y
|
||||||
@@ -9,3 +9,8 @@
|
|||||||
-1 - int()
|
-1 - int()
|
||||||
int() - float()
|
int() - float()
|
||||||
float() - 3.0
|
float() - 3.0
|
||||||
|
|
||||||
|
a = 3
|
||||||
|
b = ''
|
||||||
|
#! 2 type-error-operation
|
||||||
|
a + b
|
||||||
Reference in new issue
Block a user