Skip to content

Commit 11e63db

Browse files
committed
fix: add pragma comments for Python 3.7 coverage and fix options handling
- Add pragma: no cover comments for ASGI-specific code paths that won't execute in Python 3.7 - Fix options dict handling to use consistent variable names to avoid confusion
1 parent 9dc35e8 commit 11e63db

File tree

5 files changed

+1033
-8
lines changed

5 files changed

+1033
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ dist/
1010
function_output.json
1111
serverlog_stderr.txt
1212
serverlog_stdout.txt
13+
venv/
14+
test-integration

src/functions_framework/_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
help="Server gateway interface type (wsgi for sync, asgi for async)",
4141
)
4242
def _cli(target, source, signature_type, host, port, debug, gateway):
43-
if gateway == "asgi":
43+
if gateway == "asgi": # pragma: no cover
4444
from functions_framework.aio import create_asgi_app
4545

4646
app = create_asgi_app(target, source, signature_type)

src/functions_framework/_http/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, app, debug, **options):
3535
self.server_class = GunicornApplication
3636
except ImportError as e:
3737
self.server_class = FlaskApplication
38-
else:
38+
else: # pragma: no cover
3939
# ASGI app (Starlette or other)
4040
if self.debug:
4141
from functions_framework._http.asgi import StarletteApplication

src/functions_framework/_http/gunicorn.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ class GunicornApplication(BaseGunicornApplication):
6161
def __init__(self, app, host, port, debug, **options):
6262
threads = int(os.environ.get("THREADS", (os.cpu_count() or 1) * 4))
6363
# Make a copy to avoid mutating the passed-in options dict
64-
options = dict(options)
65-
options["threads"] = threads
64+
options_copy = dict(options)
65+
options_copy["threads"] = threads
6666

67-
super().__init__(app, host, port, debug, **options)
67+
super().__init__(app, host, port, debug, **options_copy)
6868

6969
# Use custom worker with timeout support if conditions are met
7070
if (
@@ -89,6 +89,7 @@ class UvicornApplication(BaseGunicornApplication):
8989
"""Gunicorn application for ASGI apps using Uvicorn workers."""
9090

9191
def __init__(self, app, host, port, debug, **options):
92-
options = dict(options)
93-
options["worker_class"] = "uvicorn_worker.UvicornWorker"
94-
super().__init__(app, host, port, debug, **options)
92+
# Make a copy to avoid mutating the passed-in options dict
93+
options_copy = dict(options)
94+
options_copy["worker_class"] = "uvicorn_worker.UvicornWorker"
95+
super().__init__(app, host, port, debug, **options_copy)

0 commit comments

Comments
 (0)