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

asyncio.start_server no error if you forget host and port #7393

Closed
Akuli opened this issue Feb 27, 2022 · 1 comment
Closed

asyncio.start_server no error if you forget host and port #7393

Akuli opened this issue Feb 27, 2022 · 1 comment
Labels
reason: inexpressable Closed, because this can't be expressed within the current type system topic: asyncio Asyncio-related issues

Comments

@Akuli
Copy link
Collaborator

Akuli commented Feb 27, 2022

It will error at runtime, but not when type checking.

(env) akuli@akuli-desktop:~/typeshed$ cat foo.py
import asyncio
asyncio.run(asyncio.start_server(print))

(env) akuli@akuli-desktop:~/typeshed$ mypy foo.py
Success: no issues found in 1 source file

(env) akuli@akuli-desktop:~/typeshed$ python3 foo.py
Traceback (most recent call last):
  File "/home/akuli/typeshed/foo.py", line 2, in <module>
    asyncio.run(asyncio.start_server(print))
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/lib/python3.9/asyncio/streams.py", line 94, in start_server
    return await loop.create_server(factory, host, port, **kwds)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1504, in create_server
    raise ValueError('Neither host/port nor sock were specified')
ValueError: Neither host/port nor sock were specified
@AlexWaygood AlexWaygood added the topic: asyncio Asyncio-related issues label Apr 9, 2022
@Akuli
Copy link
Collaborator Author

Akuli commented Apr 27, 2022

I was going to make a PR that fixes this, but the error message was ridiculous, much worse than the error from runtime.

errs

This can hardly be called an improvement. Also, the runtime error typically happens when you start your app, not in some rare corner case that only happens in production at 2AM.

So in short, this can't be fixed in a way that would be practically useful, at least not without something like python/typing#1043.

@Akuli Akuli added the reason: inexpressable Closed, because this can't be expressed within the current type system label Apr 27, 2022
@Akuli Akuli closed this as completed Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reason: inexpressable Closed, because this can't be expressed within the current type system topic: asyncio Asyncio-related issues
Projects
None yet
Development

No branches or pull requests

2 participants