Skip to content

Commit 5b471db

Browse files
SONARPY-870 Use serialized version of TypeShed core modules (builtins and its dependencies) (#940)
1 parent 7028477 commit 5b471db

File tree

32 files changed

+15895
-140
lines changed

32 files changed

+15895
-140
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# force eol to LF so we don't have problem with tests on windows
22

33
* text eol=lf
4+
5+
*.protobuf binary

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ Desktop.ini
3535
# ---- Python
3636
venv
3737
__pycache__
38+
python-frontend/typeshed_serializer/serializer/proto_out

its/ruling/src/test/resources/expected/python-S2159.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
'project:numpy-1.16.4/numpy/distutils/system_info.py':[
33
259,
44
],
5-
'project:numpy-1.16.4/numpy/lib/utils.py':[
6-
571,
7-
],
85
}

its/ruling/src/test/resources/expected/python-S5607.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
'project:buildbot-0.8.6p1/buildbot/status/build.py':[
77
104,
88
],
9+
'project:django-cms-3.7.1/cms/models/metaclasses.py':[
10+
14,
11+
],
912
'project:numpy-1.16.4/tools/npy_tempita/__init__.py':[
1013
184,
1114
],
15+
'project:tensorflow/python/autograph/pyct/common_transformers/anf_test.py':[
16+
37,
17+
42,
18+
],
1219
'project:tensorflow/python/keras/layers/wrappers.py':[
1320
515,
1421
],
@@ -26,4 +33,7 @@
2633
104,
2734
105,
2835
],
36+
'project:twisted-12.1.0/twisted/test/test_defer.py':[
37+
367,
38+
],
2939
}

its/ruling/src/test/resources/expected/python-S5644.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@
77
22,
88
24,
99
],
10+
'project:twisted-12.1.0/twisted/test/test_paths.py':[
11+
166,
12+
167,
13+
],
1014
}

its/ruling/src/test/resources/expected/python-S5655.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
'project:tensorflow/python/eager/function.py':[
1515
968,
1616
],
17+
'project:twisted-12.1.0/twisted/python/components.py':[
18+
313,
19+
],
1720
}

its/ruling/src/test/resources/expected/python-S5727.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
'project:buildbot-0.8.6p1/buildbot/status/web/feeds.py':[
66
240,
77
],
8+
'project:buildbot-0.8.6p1/buildbot/steps/shell.py':[
9+
469,
10+
],
811
'project:django-2.2.3/django/core/files/locks.py':[
912
109,
1013
113,
1114
],
15+
'project:numpy-1.16.4/numpy/distutils/misc_util.py':[
16+
340,
17+
341,
18+
342,
19+
343,
20+
344,
21+
],
1222
'project:tensorflow/python/keras/layers/normalization.py':[
1323
1131,
1424
],

its/ruling/src/test/resources/expected/python-S5795.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
217,
55
],
66
'project:numpy-1.16.4/numpy/distutils/misc_util.py':[
7+
340,
8+
341,
9+
342,
10+
343,
11+
344,
712
476,
813
],
914
'project:numpy-1.16.4/numpy/ma/core.py':[

python-checks/src/test/resources/checks/incompatibleOperands/arithmetic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ def __neg__(self):
5959

6060
def builtin_noncompliant():
6161
1 + "1" # Noncompliant
62+
"1" + 1 # Noncompliant
6263
1 + [1] # Noncompliant
6364
1 + {1} # Noncompliant
6465
1 + (1,) # Noncompliant
6566
1 + {'a': 1} # Noncompliant
6667
[1] + (1,) # Noncompliant
68+
"foo " + "bar".encode('base64') # OK, FP in Python2
69+
"bar".encode('base64') + "foo" # OK, FP in Python2
6770

6871

6972
-'1' # Noncompliant

python-checks/src/test/resources/checks/itemOperationsTypeCheck/itemOperations_delitem.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def builtin_types_supporting_delitem():
1616
def builtin_types_not_supporting_delitem():
1717
# dictviews https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects
1818
mydict = {'a': 1, 'b': 2}
19-
del mydict.keys()[0] # OK: FP in Python 2
20-
del mydict.values()[0] # OK: FP in Python 2
21-
del mydict.items()[0] # OK: FP in Python 2
19+
del mydict.keys()[0] # Noncompliant
20+
del mydict.values()[0] # Noncompliant
21+
del mydict.items()[0] # Noncompliant
2222

2323
# iterators
2424
del iter(mylist)[0] # Noncompliant
@@ -48,7 +48,7 @@ def builtin_types_not_supporting_delitem():
4848
var = None
4949
del var[0] # Noncompliant
5050

51-
del bytes(b'123')[0] # FN: unknown return type
51+
del bytes(b'123')[0] # Noncompliant
5252
del memoryview(bytearray(b'abc'))[0] # Noncompliant
5353

5454
del "abc"[0] # Noncompliant

0 commit comments

Comments
 (0)