Skip to content

Commit 0e35697

Browse files
roberto-orlandi-sonarsourcesonartech
authored andcommitted
SONARSEC-7358 Implement google-genai stub on sonar-python plugin (#539)
GitOrigin-RevId: c79ddc13d0d01786e2087657076f2fcf0db47f9c
1 parent f1dd003 commit 0e35697

10 files changed

Lines changed: 103 additions & 3 deletions

File tree

‎python-frontend/src/main/resources/org/sonar/python/types/custom_protobuf/google.genai.client.protobuf‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
google.genai.client�
3+
AsyncClientgoogle.genai.client.AsyncClient"*SonarPythonAnalyzerFakeStub.CustomStubBasert
4+
models&google.genai.client.AsyncClient.modelsB
5+
google.genai.models.AsyncModels"google.genai.models.AsyncModels�
6+
Clientgoogle.genai.client.Client"*SonarPythonAnalyzerFakeStub.CustomStubBasere
7+
models!google.genai.client.Client.models8
8+
google.genai.models.Models"google.genai.models.Modelsri
9+
aiogoogle.genai.client.Client.aioB
10+
google.genai.client.AsyncClient"google.genai.client.AsyncClient*�
11+
__annotations__#google.genai.client.__annotations__W
12+
builtins.dict[builtins.str,Any]
13+
builtins.str" builtins.str
14+
Any"builtins.dict

‎python-frontend/src/main/resources/org/sonar/python/types/custom_protobuf/google.genai.models.protobuf‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
google.genai.models�
3+
Modelsgoogle.genai.models.Models"*SonarPythonAnalyzerFakeStub.CustomStubBase*�
4+
generate_content+google.genai.models.Models.generate_content"
5+
Any*B
6+
self8
7+
google.genai.models.Models"google.genai.models.Models*
8+
args
9+
Any*
10+
kwargs
11+
Any*�
12+
generate_content_stream2google.genai.models.Models.generate_content_stream"
13+
Any*B
14+
self8
15+
google.genai.models.Models"google.genai.models.Models*
16+
args
17+
Any*
18+
kwargs
19+
Any�
20+
AsyncModelsgoogle.genai.models.AsyncModels"*SonarPythonAnalyzerFakeStub.CustomStubBase*�
21+
generate_content0google.genai.models.AsyncModels.generate_content"
22+
Any*L
23+
selfB
24+
google.genai.models.AsyncModels"google.genai.models.AsyncModels*
25+
args
26+
Any*
27+
kwargs
28+
Any*�
29+
generate_content_stream7google.genai.models.AsyncModels.generate_content_stream"
30+
Any*L
31+
selfB
32+
google.genai.models.AsyncModels"google.genai.models.AsyncModels*
33+
args
34+
Any*
35+
kwargs
36+
Any*�
37+
__annotations__#google.genai.models.__annotations__W
38+
builtins.dict[builtins.str,Any]
39+
builtins.str" builtins.str
40+
Any"builtins.dict

‎python-frontend/src/main/resources/org/sonar/python/types/custom_protobuf/google.genai.protobuf‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
google.genai�
3+
Clientgoogle.genai.client.Client"*SonarPythonAnalyzerFakeStub.CustomStubBasere
4+
models!google.genai.client.Client.models8
5+
google.genai.models.Models"google.genai.models.Modelsri
6+
aiogoogle.genai.client.Client.aioB
7+
google.genai.client.AsyncClient"google.genai.client.AsyncClient*m
8+
__path__google.genai.__path__J
9+
builtins.list[builtins.str]
10+
builtins.str" builtins.str"builtins.list*�
11+
__annotations__google.genai.__annotations__W
12+
builtins.dict[builtins.str,Any]
13+
builtins.str" builtins.str
14+
Any"builtins.dict

‎python-frontend/src/main/resources/org/sonar/python/types/custom_protobuf/google.protobuf‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
google*g
3+
__path__google.__path__J
4+
builtins.list[builtins.str]
5+
builtins.str" builtins.str"builtins.list*�
6+
__annotations__google.__annotations__W
7+
builtins.dict[builtins.str,Any]
8+
builtins.str" builtins.str
9+
Any"builtins.dict
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
a75027f06ddfce450cb8755bf68ada53d69434d79981d68c626e6057ad3271bb
2-
c40ff522ce358ba12f18a208f96127e1a917e2c6b8a5df7b5d47e770381cfc61
1+
7c8abac9a11830e8185e4aa006376b4966d74a5461f1cafc76bbb09ff0c446f2
2+
2931cf47098ed57dc10f0ea1b8ea1f61b6a6a4f217ca213d8267b9522efa850f

‎python-frontend/typeshed_serializer/resources/custom/google/__init__.pyi‎

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from google.genai.client import Client
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from SonarPythonAnalyzerFakeStub import CustomStubBase
2+
from google.genai.models import AsyncModels, Models
3+
4+
5+
class AsyncClient(CustomStubBase):
6+
models: AsyncModels
7+
8+
9+
class Client(CustomStubBase):
10+
models: Models
11+
aio: AsyncClient
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from SonarPythonAnalyzerFakeStub import CustomStubBase
2+
from typing import Any
3+
4+
5+
class Models(CustomStubBase):
6+
def generate_content(self, *args, **kwargs) -> Any: ...
7+
def generate_content_stream(self, *args, **kwargs) -> Any: ...
8+
9+
class AsyncModels(CustomStubBase):
10+
def generate_content(self, *args, **kwargs) -> Any: ...
11+
def generate_content_stream(self, *args, **kwargs) -> Any: ...

‎python-frontend/typeshed_serializer/tests/test_serializers.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_custom_stubs_serializer(typeshed_custom_stubs):
7474
custom_stubs_serializer.serialize()
7575
assert custom_stubs_serializer.get_build_result.call_count == 1
7676
# Not every files from "typeshed_custom_stubs" build are serialized, as some are builtins
77-
assert symbols.save_module.call_count == 260
77+
assert symbols.save_module.call_count == 264
7878

7979

8080
def test_importer_serializer():

0 commit comments

Comments
 (0)