[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2025-08-13 15:16:20 +00:00
parent 92345b25de
commit 13beeeeffb
2 changed files with 10 additions and 2 deletions

View File

@ -1,10 +1,12 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
class Endpoint(ABC): class Endpoint(ABC):
@abstractmethod @abstractmethod
def parse(self, options): def parse(self, options):
pass pass
class TCPEndpoint(Endpoint): class TCPEndpoint(Endpoint):
def parse(self, options): def parse(self, options):
if options.get("port") and options.get("host"): if options.get("port") and options.get("host"):
@ -14,20 +16,24 @@ class TCPEndpoint(Endpoint):
raise ValueError("TCP binding requires both port and host kwargs.") raise ValueError("TCP binding requires both port and host kwargs.")
return None return None
class UNIXEndpoint(Endpoint): class UNIXEndpoint(Endpoint):
def parse(self, options): def parse(self, options):
if options.get("unix_socket"): if options.get("unix_socket"):
return f"unix:{options['unix_socket']}" return f"unix:{options['unix_socket']}"
return None return None
class FileDescriptorEndpoint(Endpoint): class FileDescriptorEndpoint(Endpoint):
def parse(self, options): def parse(self, options):
if options.get("file_descriptor") is not None: if options.get("file_descriptor") is not None:
return f"fd:fileno={int(options['file_descriptor'])}" return f"fd:fileno={int(options['file_descriptor'])}"
return None return None
endpoint_parsers = [TCPEndpoint(), UNIXEndpoint(), FileDescriptorEndpoint()] endpoint_parsers = [TCPEndpoint(), UNIXEndpoint(), FileDescriptorEndpoint()]
def build_endpoint_description_strings(**kwargs): def build_endpoint_description_strings(**kwargs):
""" """
Build a list of twisted endpoint description strings that the server will listen on. Build a list of twisted endpoint description strings that the server will listen on.

View File

@ -5,10 +5,12 @@ from unittest import TestCase, skipUnless
from daphne.cli import CommandLineInterface from daphne.cli import CommandLineInterface
from daphne.endpoints import ( from daphne.endpoints import (
build_endpoint_description_strings as build,
endpoint_parsers,
Endpoint, Endpoint,
) )
from daphne.endpoints import build_endpoint_description_strings as build
from daphne.endpoints import (
endpoint_parsers,
)
class TestEndpointDescriptions(TestCase): class TestEndpointDescriptions(TestCase):