Skip to content

Commit 18fbb00

Browse files
SONARPY-1131 Fix FP on S930 due to outdated Flask stubs for send_file() API (#1308)
1 parent 5b0e767 commit 18fbb00

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

python-checks/src/test/resources/checks/argumentNumber.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,14 @@ def method2(self, a):
176176
self.method1(self, a=a) # S5549 scope
177177
"{self}".format(self=self) # Ok
178178

179+
180+
181+
def flask_send_file():
182+
# make sure no FPs are raised on flask.send_file
183+
from flask import send_file
184+
return send_file(
185+
status.message,
186+
mimetype=APPLICATION_MIME_TYPE,
187+
as_attachment=True,
188+
download_name=f"{analytics.filename}.zip",
189+
)

python-frontend/src/main/resources/org/sonar/python/types/third_party_protobuf/flask.helpers.protobuf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ __module__/flask.helpers.locked_cached_property.__module__
120120
with_categories
121121
builtins.bool"builtins.bool *
122122
category_filter
123-
Any z35z36z37z38z39z310�
123+
Any z35z36z37z38z39z310�
124124
send_fileflask.helpers.send_file"2
125125
flask.wrappers.Response"flask.wrappers.Response*
126126
filename_or_fp
@@ -146,7 +146,11 @@ __module__/flask.helpers.locked_cached_property.__module__
146146
last_modified&
147147
Union[Any,None]
148148
Any
149-
None z35z36z37z38z39z310v
149+
None *
150+
args
151+
Any*
152+
kwargs
153+
Anyz35z36z37z38z39z310v
150154
safe_joinflask.helpers.safe_join"
151155
Any*
152156
directory

python-frontend/src/main/resources/org/sonar/python/types/third_party_protobuf/flask.protobuf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ url_prefix%flask.blueprints.Blueprint.url_prefixD
13511351
directory
13521352
Any*
13531353
pathnames
1354-
Anyz35z36z37z38z39z310�
1354+
Anyz35z36z37z38z39z310�
13551355
send_fileflask.helpers.send_file"2
13561356
flask.wrappers.Response"flask.wrappers.Response*
13571357
filename_or_fp
@@ -1377,7 +1377,11 @@ url_prefix%flask.blueprints.Blueprint.url_prefixD
13771377
last_modified&
13781378
Union[Any,None]
13791379
Any
1380-
None z35z36z37z38z39z310�
1380+
None *
1381+
args
1382+
Any*
1383+
kwargs
1384+
Anyz35z36z37z38z39z310�
13811385
send_from_directory!flask.helpers.send_from_directory"2
13821386
flask.wrappers.Response"flask.wrappers.Response*
13831387
directory

python-frontend/typeshed_serializer/resources/typeshed-internal/stubs/Flask/flask/helpers.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def send_file(
2121
cache_timeout: Optional[Any] = ...,
2222
conditional: bool = ...,
2323
last_modified: Optional[Any] = ...,
24+
*args: Any,
25+
**kwargs: Any
2426
) -> Response: ...
2527
def safe_join(directory: Any, *pathnames: Any): ...
2628
def send_from_directory(directory: Any, filename: Any, **options: Any) -> Response: ...

0 commit comments

Comments
 (0)