Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factorize hypercon.Config() creation #3234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pquentin
Copy link
Member

I have the same changes ready for #3230, I'll update whichever pull request gets merged last.

@pquentin pquentin added the Skip Changelog Pull requests that don't require a changelog entry label Dec 15, 2023
Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Quentin!

@sethmlarson
Copy link
Member

@pquentin Looks like potential failures on the certificate tests, might be related?

@pquentin
Copy link
Member Author

Definitely related, thanks.

@@ -62,7 +76,7 @@ def run_hypercorn_in_thread(
if not ready_event.is_set():
raise Exception("most likely failed to start server")

yield
yield typing.cast(int, parse_url(config.bind[0]).port)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
yield typing.cast(int, parse_url(config.bind[0]).port)
port = parse_url(config.bind[0]).port
assert port is not None
yield port

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When can this happen?

config: hypercorn.Config, app: hypercorn.typing.ASGIFramework
) -> Generator[None, None, None]:
host: str, certs: dict[str, typing.Any] | None, app: hypercorn.typing.ASGIFramework
) -> typing.Iterator[int]:
Copy link
Contributor

@graingert graingert Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterator is technically the wrong type, because contextmanager incorrectly accepts an object without .throw. This bug might get fixed in typeshed

Suggested change
) -> typing.Iterator[int]:
) -> Generator[int, None, None]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog Pull requests that don't require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants