Skip to content

Commit

Permalink
Rebase correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Apr 13, 2024
1 parent 565d654 commit 7cbca8b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
14 changes: 7 additions & 7 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import annotations

import configparser
import io
import json
import logging
import os
Expand Down Expand Up @@ -367,22 +371,18 @@ def test_log_config_yaml(
mocked_logging_config_module.dictConfig.assert_called_once_with(logging_config)


@pytest.mark.parametrize(
"config_file", ["log_config.ini", configparser.ConfigParser(), io.StringIO()]
)
@pytest.mark.parametrize("config_file", ["log_config.ini", configparser.ConfigParser(), io.StringIO()])
def test_log_config_file(
mocked_logging_config_module: MagicMock,
config_file: typing.Union[str, configparser.RawConfigParser, typing.IO],
config_file: str | configparser.RawConfigParser | typing.IO[Any],
) -> None:
"""
Test that one can load a configparser config from disk.
"""
config = Config(app=asgi_app, log_config=config_file)
config.load()

mocked_logging_config_module.fileConfig.assert_called_once_with(
"log_config", disable_existing_loggers=False
)
mocked_logging_config_module.fileConfig.assert_called_once_with(config_file, disable_existing_loggers=False)


@pytest.fixture(params=[0, 1])
Expand Down
11 changes: 1 addition & 10 deletions uvicorn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@
import sys
from configparser import RawConfigParser
from pathlib import Path
from typing import Any, Awaitable, Callable, Literal
from typing import (
IO,
Any,
Awaitable,
Callable,
Dict,
List,
Literal,
Optional,
Tuple,
Type,
Union,
)

import click
Expand Down Expand Up @@ -380,9 +373,7 @@ def configure_logging(self) -> None:
with open(self.log_config) as file:
loaded_config = json.load(file)
logging.config.dictConfig(loaded_config)
elif isinstance(self.log_config, str) and self.log_config.endswith(
(".yaml", ".yml")
):
elif isinstance(self.log_config, str) and self.log_config.endswith((".yaml", ".yml")):
# Install the PyYAML package or the uvicorn[standard] optional
# dependencies to enable this functionality.
import yaml
Expand Down
2 changes: 1 addition & 1 deletion uvicorn/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import platform
import ssl
import sys
from typing import Any, Callable, IO
from typing import IO, Any, Callable

import click

Expand Down

0 comments on commit 7cbca8b

Please sign in to comment.