cirospaciari / socketify.py

Bringing Http/Https and WebSockets High Performance servers for PyPy3 and Python3
https://www.socketify.dev
MIT License
1.44k stars 56 forks source link

socketify.AppOptions defaults are not working as expected #86

Closed bob-rove closed 1 year ago

bob-rove commented 1 year ago

Describe the bug

When trying to run examples/https.py I had to specify all AppOptions defaults.

To Reproduce

Follow #85 and discover that AppOptions require all defaults to be passed explicitly. Namely, without the following arguments:

        dh_params_file_name=None,
        ca_file_name=None,
        ssl_ciphers=None,

running examples/https.py will throw exceptions like this one:

Traceback (most recent call last):
...
  File "<string>", line 10, in __init__
  File "/usr/local/lib/python3.9/site-packages/socketify/socketify.py", line 3355, in __post_init__
    raise RuntimeError("dh_params_file_name must be a str if specified")
RuntimeError: dh_params_file_name must be a str if specified

Expected behavior

No error should expected when one of the optional parameters missing.

Additional context

AppOptions attributes should probably be defined with None defaults:

class AppOptions:
    key_file_name: str = None
    cert_file_name: str = None
    ...

instead of a tuple (perhaps it's a typo):

class AppOptions:
    key_file_name: str = (None,)
    cert_file_name: str = (None,)
    ...
cirospaciari commented 1 year ago

Yeah some refactor break it, will push the fix today thanks for reporting