Skip to content

Commit 80385e8

Browse files
committed
fix: apply black and isort formatting to source files
1 parent 9ea1d5c commit 80385e8

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

src/functions_framework/_cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@
3737
envvar="GATEWAY",
3838
type=click.Choice(["wsgi", "asgi"]),
3939
default="wsgi",
40-
help="Server gateway interface type (wsgi for sync, asgi for async)"
40+
help="Server gateway interface type (wsgi for sync, asgi for async)",
4141
)
4242
def _cli(target, source, signature_type, host, port, debug, gateway):
4343
if gateway == "asgi":
4444
from functions_framework.aio import create_asgi_app
45+
4546
app = create_asgi_app(target, source, signature_type)
4647
else:
4748
app = create_app(target, source, signature_type)
48-
49+
4950
create_server(app, debug).run(host, port)

src/functions_framework/_http/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, app, debug, **options):
2222
self.app = app
2323
self.debug = debug
2424
self.options = options
25-
25+
2626
# Check if app is Flask (WSGI) or not (ASGI)
2727
if isinstance(app, Flask):
2828
# WSGI app
@@ -31,20 +31,24 @@ def __init__(self, app, debug, **options):
3131
else:
3232
try:
3333
from functions_framework._http.gunicorn import GunicornApplication
34+
3435
self.server_class = GunicornApplication
3536
except ImportError as e:
3637
self.server_class = FlaskApplication
3738
else:
3839
# ASGI app (Starlette or other)
3940
if self.debug:
4041
from functions_framework._http.asgi import StarletteApplication
42+
4143
self.server_class = StarletteApplication
4244
else:
4345
try:
4446
from functions_framework._http.gunicorn import UvicornApplication
47+
4548
self.server_class = UvicornApplication
4649
except ImportError as e:
4750
from functions_framework._http.asgi import StarletteApplication
51+
4852
self.server_class = StarletteApplication
4953

5054
def run(self, host, port):

src/functions_framework/_http/asgi.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
class StarletteApplication:
1919
"""A Starlette application that uses Uvicorn for direct serving (development mode)."""
20-
20+
2121
def __init__(self, app, host, port, debug, **options):
2222
"""Initialize the Starlette application.
23-
23+
2424
Args:
2525
app: The ASGI application to serve
2626
host: The host to bind to
@@ -32,19 +32,14 @@ def __init__(self, app, host, port, debug, **options):
3232
self.host = host
3333
self.port = port
3434
self.debug = debug
35-
35+
3636
# Default uvicorn config
3737
self.options = {
3838
"log_level": "debug" if debug else "error",
3939
"reload": debug,
4040
}
4141
self.options.update(options)
42-
42+
4343
def run(self):
4444
"""Run the Uvicorn server directly."""
45-
uvicorn.run(
46-
self.app,
47-
host=self.host,
48-
port=int(self.port),
49-
**self.options
50-
)
45+
uvicorn.run(self.app, host=self.host, port=int(self.port), **self.options)

src/functions_framework/_http/gunicorn.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
class BaseGunicornApplication(gunicorn.app.base.BaseApplication):
3131
"""Base Gunicorn application with common configuration."""
32+
3233
def __init__(self, app, host, port, debug, **options):
3334
global TIMEOUT_SECONDS
3435
TIMEOUT_SECONDS = int(os.environ.get("CLOUD_RUN_TIMEOUT_SECONDS", 0))
@@ -56,12 +57,13 @@ def load(self):
5657

5758
class GunicornApplication(BaseGunicornApplication):
5859
"""Gunicorn application for WSGI apps with gthread worker support."""
60+
5961
def __init__(self, app, host, port, debug, **options):
6062
threads = int(os.environ.get("THREADS", (os.cpu_count() or 1) * 4))
6163
options["threads"] = threads
62-
64+
6365
super().__init__(app, host, port, debug, **options)
64-
66+
6567
# Use custom worker with timeout support if conditions are met
6668
if (
6769
TIMEOUT_SECONDS > 0
@@ -83,7 +85,8 @@ def handle_request(self, req, conn):
8385

8486
class UvicornApplication(BaseGunicornApplication):
8587
"""Gunicorn application for ASGI apps using Uvicorn workers."""
88+
8689
def __init__(self, app, host, port, debug, **options):
8790
super().__init__(app, host, port, debug, **options)
88-
91+
8992
self.options["worker_class"] = "uvicorn_worker.UvicornWorker"

0 commit comments

Comments
 (0)