sasha-tkachev / fastapi-cloudevents

CloudEvents FastAPI plugin. Allows to easily consume and produce events in CloudEvents format over REST API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Altered or corrupted file `fastapi_cloudevents/cloudevent_response.py` in v2.0.0 release

sebbae opened this issue · comments

Hi @sasha-tkachev,

I hope you and your loved ones are doing well in these cruel times.

I encountered an issue with one of the files of the last 2.0.0 release, which is different than the source file in the repository.

Describe the bug
The file cloudevent_response.py in the release tarball fastapi-cloudevents-2.0.0.tar.gz differs from the source file in the repo fastapi_cloudevents/cloudevent_response.py and the source tarball v2.0.0.tar.gz

Concretely the diff looks like this:

@@ -63,7 +63,7 @@
         )

     @classmethod
-    def configured(cls, settings: CloudEventSettings) -> Type["_CloudEventResponse"]:
+    def configured(cls, settings: CloudEventSettings) -> Type["_CloudEventResponse:q:"]:
         class ConfiguredStructuredCloudEventResponse(cls):
             _settings = settings

To Reproduce

Prepare a clean test environment:

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install fastapi_cloudevents==2.0.0

Try to import the fastapi_cloudevents

python3 -c "import fastapi_cloudevents"

and see the error message:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/typing.py", line 850, in __init__
    code = compile(arg_to_compile, '<string>', 'eval')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1
    _CloudEventResponse:q:
                       ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/sebbae/bugreport/.venv/lib/python3.11/site-packages/fastapi_cloudevents/__init__.py", line 3, in <module>
    from fastapi_cloudevents.cloudevent_response import (
  File "/Users/sebbae/bugreport/.venv/lib/python3.11/site-packages/fastapi_cloudevents/cloudevent_response.py", line 43, in <module>
    class StructuredCloudEventResponse(JSONResponse, _CloudEventResponse):
  File "/Users/sebbae/bugreport/.venv/lib/python3.11/site-packages/fastapi_cloudevents/cloudevent_response.py", line 66, in StructuredCloudEventResponse
    def configured(cls, settings: CloudEventSettings) -> Type["_CloudEventResponse:q:"]:
                                                         ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/typing.py", line 352, in inner
    return cached(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/typing.py", line 1561, in __getitem__
    params = tuple(_type_check(p, msg) for p in params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/typing.py", line 1561, in <genexpr>
    params = tuple(_type_check(p, msg) for p in params)
                   ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/typing.py", line 186, in _type_check
    arg = _type_convert(arg, module=module, allow_special_forms=allow_special_forms)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/typing.py", line 164, in _type_convert
    return ForwardRef(arg, module=module, is_class=allow_special_forms)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/typing.py", line 852, in __init__
    raise SyntaxError(f"Forward reference must be an expression -- got {arg!r}")
SyntaxError: Forward reference must be an expression -- got '_CloudEventResponse:q:'

Expected behavior
Having the same files in the released package as in the tagged GH release and no error when importing the package.

I confirm the issue!

@sebbae and @willianrampazzo, thank you for reporting!
Fixed and released it in v2.0.1