|
10 | 10 | from collections.abc import AsyncIterator, Iterator |
11 | 11 | from contextlib import ExitStack, closing |
12 | 12 | from tempfile import NamedTemporaryFile |
13 | | -from typing import TYPE_CHECKING, Literal, TypeVar |
| 13 | +from typing import TYPE_CHECKING, Literal, TypeVar, get_args |
14 | 14 |
|
15 | 15 | from _util import create_standard_streams |
16 | 16 | from gen.connectrpc.conformance.v1.config_pb2 import Code as ConformanceCode |
@@ -655,17 +655,18 @@ def _find_free_port(): |
655 | 655 | return s.getsockname()[1] |
656 | 656 |
|
657 | 657 |
|
| 658 | +Server = Literal["daphne", "granian", "gunicorn", "hypercorn", "uvicorn"] |
| 659 | + |
| 660 | + |
658 | 661 | class Args(argparse.Namespace): |
659 | 662 | mode: Literal["sync", "async"] |
660 | | - server: Literal["daphne", "granian", "hypercorn", "uvicorn"] |
| 663 | + server: Server |
661 | 664 |
|
662 | 665 |
|
663 | 666 | async def main() -> None: |
664 | 667 | parser = argparse.ArgumentParser(description="Conformance server") |
665 | 668 | parser.add_argument("--mode", choices=["sync", "async"]) |
666 | | - parser.add_argument( |
667 | | - "--server", choices=["daphne", "granian", "gunicorn", "hypercorn", "uvicorn"] |
668 | | - ) |
| 669 | + parser.add_argument("--server", choices=get_args(Server)) |
669 | 670 | args = parser.parse_args(namespace=Args()) |
670 | 671 |
|
671 | 672 | stdin, stdout = await create_standard_streams() |
|
0 commit comments