Skip to content

NotImplementedError: Union of types not supported #80

Description

@Dimasbka

Steps to reproduce:

Python 3.12.12
faust-streaming = 0.13.0
mode-streaming = 0.5.3

After updating mode-streaming (0.4.1 -> 0.5.3), errors occur when describing failure models.

I removed all other dependencies, the minimum script to reproduce the error test.py :

from faust import Record


class SensitiveInfo(Record):
    data: str | list | dict | None
    meta: dict


if __name__ == '__main__':
    print('OK')

Expected behavior

(python3.12)$ python test.py
ok

Actual behavior

(python3.12)$ python test.py
Traceback (most recent call last):
  File "/test/test.py", line 5, in <module>
    class SensitiveInfo(Record):
  File "/test/.venv/lib/python3.12/site-packages/faust/models/record.py", line 115, in __init_subclass__
    super().__init_subclass__(
  File "/test/.venv/lib/python3.12/site-packages/faust/models/base.py", line 298, in __init_subclass__
    finalizer()
  File "/test/.venv/lib/python3.12/site-packages/faust/models/base.py", line 376, in _init_subclass
    options.descriptors = cls._contribute_field_descriptors(cls, options)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/.venv/lib/python3.12/site-packages/faust/models/record.py", line 286, in _contribute_field_descriptors
    descr.on_model_attached()
  File "/test/.venv/lib/python3.12/site-packages/faust/models/fields.py", line 172, in on_model_attached
    self._to_python = self._compile_type_expression()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/.venv/lib/python3.12/site-packages/faust/models/fields.py", line 185, in _compile_type_expression
    comprehension = expr.as_function(stacklevel=2)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/.venv/lib/python3.12/site-packages/faust/models/typing.py", line 675, in as_function
    sourcecode = self.as_string(name=name, argument_name=argument_name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/.venv/lib/python3.12/site-packages/faust/models/typing.py", line 692, in as_string
    expression = self.as_comprehension(argument_name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/.venv/lib/python3.12/site-packages/faust/models/typing.py", line 701, in as_comprehension
    return self.build(Variable(argument_name), self.expr)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/.venv/lib/python3.12/site-packages/faust/models/typing.py", line 704, in build
    return self._build_expression(var, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/.venv/lib/python3.12/site-packages/faust/models/typing.py", line 709, in _build_expression
    res = node.build(var, *type_info.args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/test/.venv/lib/python3.12/site-packages/faust/models/typing.py", line 334, in build
    raise NotImplementedError(f"Union of types {args!r} not supported")
NotImplementedError: Union of types (<class 'str'>, <class 'list'>, <class 'dict'>, <class 'NoneType'>) not supported

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions