Skip to content

Commit

Permalink
Remove --debug flag (#1640)
Browse files Browse the repository at this point in the history
* Remove debug flag

* Drop 0.04 coverage
  • Loading branch information
Kludex committed Sep 14, 2022
1 parent 591462d commit 791c246
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 104 deletions.
3 changes: 1 addition & 2 deletions setup.cfg
Expand Up @@ -20,7 +20,6 @@ files =
uvicorn/protocols/http/auto.py,
uvicorn/protocols/websockets/auto.py,
uvicorn/supervisors/__init__.py,
uvicorn/middleware/debug.py,
uvicorn/middleware/wsgi.py,
uvicorn/supervisors/watchfilesreload.py,
uvicorn/supervisors/watchgodreload.py,
Expand Down Expand Up @@ -82,7 +81,7 @@ plugins =

[coverage:report]
precision = 2
fail_under = 97.74
fail_under = 97.69
show_missing = true
skip_covered = true
exclude_lines =
Expand Down
73 changes: 0 additions & 73 deletions tests/middleware/test_debug.py

This file was deleted.

19 changes: 3 additions & 16 deletions tests/test_config.py
Expand Up @@ -14,7 +14,6 @@
from tests.utils import as_cwd
from uvicorn._types import Environ, StartResponse
from uvicorn.config import Config
from uvicorn.middleware.debug import DebugMiddleware
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
from uvicorn.middleware.wsgi import WSGIMiddleware
from uvicorn.protocols.http.h11_impl import H11Protocol
Expand Down Expand Up @@ -58,28 +57,16 @@ def wsgi_app(environ: Environ, start_response: StartResponse) -> None:
pass # pragma: nocover


def test_debug_app() -> None:
config = Config(app=asgi_app, debug=True, proxy_headers=False)
config.load()

assert config.debug is True
assert isinstance(config.loaded_app, DebugMiddleware)


@pytest.mark.parametrize(
"app, expected_should_reload",
[(asgi_app, False), ("tests.test_config:asgi_app", True)],
)
def test_config_should_reload_is_set(
app: "ASGIApplication", expected_should_reload: bool
) -> None:
config_debug = Config(app=app, debug=True)
assert config_debug.debug is True
assert config_debug.should_reload is expected_should_reload

config_reload = Config(app=app, reload=True)
assert config_reload.reload is True
assert config_reload.should_reload is expected_should_reload
config = Config(app=app, reload=True)
assert config.reload is True
assert config.should_reload is expected_should_reload


def test_should_warn_on_invalid_reload_configuration(
Expand Down
7 changes: 1 addition & 6 deletions uvicorn/config.py
Expand Up @@ -42,7 +42,6 @@

from uvicorn.importer import ImportFromStringError, import_from_string
from uvicorn.middleware.asgi2 import ASGI2Middleware
from uvicorn.middleware.debug import DebugMiddleware
from uvicorn.middleware.message_logger import MessageLoggerMiddleware
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
from uvicorn.middleware.wsgi import WSGIMiddleware
Expand Down Expand Up @@ -228,7 +227,6 @@ def __init__(
access_log: bool = True,
use_colors: Optional[bool] = None,
interface: InterfaceType = "auto",
debug: bool = False,
reload: bool = False,
reload_dirs: Optional[Union[List[str], str]] = None,
reload_delay: float = 0.25,
Expand Down Expand Up @@ -275,7 +273,6 @@ def __init__(
self.access_log = access_log
self.use_colors = use_colors
self.interface = interface
self.debug = debug
self.reload = reload
self.reload_delay = reload_delay
self.workers = workers or 1
Expand Down Expand Up @@ -511,8 +508,6 @@ def load(self) -> None:
elif self.interface == "asgi2":
self.loaded_app = ASGI2Middleware(self.loaded_app)

if self.debug:
self.loaded_app = DebugMiddleware(self.loaded_app)
if logger.level <= TRACE_LOG_LEVEL:
self.loaded_app = MessageLoggerMiddleware(self.loaded_app)
if self.proxy_headers:
Expand Down Expand Up @@ -589,4 +584,4 @@ def bind_socket(self) -> socket.socket:

@property
def should_reload(self) -> bool:
return isinstance(self.app, str) and (self.debug or self.reload)
return isinstance(self.app, str) and self.reload
7 changes: 0 additions & 7 deletions uvicorn/main.py
Expand Up @@ -79,9 +79,6 @@ def print_version(ctx: click.Context, param: click.Parameter, value: bool) -> No
@click.option(
"--fd", type=int, default=None, help="Bind to socket from this file descriptor."
)
@click.option(
"--debug", is_flag=True, default=False, help="Enable debug mode.", hidden=True
)
@click.option("--reload", is_flag=True, default=False, help="Enable auto-reload.")
@click.option(
"--reload-dir",
Expand Down Expand Up @@ -372,7 +369,6 @@ def main(
ws_per_message_deflate: bool,
lifespan: LifespanType,
interface: InterfaceType,
debug: bool,
reload: bool,
reload_dirs: typing.List[str],
reload_includes: typing.List[str],
Expand Down Expand Up @@ -424,7 +420,6 @@ def main(
log_level=log_level,
access_log=access_log,
interface=interface,
debug=debug,
reload=reload,
reload_dirs=reload_dirs or None,
reload_includes=reload_includes or None,
Expand Down Expand Up @@ -471,7 +466,6 @@ def run(
ws_per_message_deflate: bool = True,
lifespan: LifespanType = "auto",
interface: InterfaceType = "auto",
debug: bool = False,
reload: bool = False,
reload_dirs: typing.Optional[typing.Union[typing.List[str], str]] = None,
reload_includes: typing.Optional[typing.Union[typing.List[str], str]] = None,
Expand Down Expand Up @@ -524,7 +518,6 @@ def run(
ws_per_message_deflate=ws_per_message_deflate,
lifespan=lifespan,
interface=interface,
debug=debug,
reload=reload,
reload_dirs=reload_dirs,
reload_includes=reload_includes,
Expand Down

0 comments on commit 791c246

Please sign in to comment.