gemini-code-assist[bot] commented on code in PR #38325:
URL: https://github.com/apache/beam/pull/38325#discussion_r3162785701
##########
sdks/python/apache_beam/typehints/schemas.py:
##########
@@ -258,34 +258,34 @@ def schema_field(
description=description)
-def _python_any_schema_pb2():
+def _python_any_schema_pb2(has_repr):
# A portable schema matches FastPrimitivesCoder encoded values
+ representation = schema_pb2.FieldType(
+ nullable=False,
+ row_type=schema_pb2.RowType(
+ schema=schema_pb2.Schema(
+ fields=[
+ schema_pb2.Field(
+ name=_PYTHON_ANY_FIELD_TYPE_BYTE,
+ type=schema_pb2.FieldType(
+ atomic_type=schema_pb2.BYTE, nullable=False)),
+ schema_pb2.Field(
+ name=_PYTHON_ANY_FIELD_PAYLOAD,
+ type=schema_pb2.FieldType(
+ atomic_type=schema_pb2.BYTES, nullable=False))
+ ],
+ options=[
+ schema_pb2.Option(
+ name=_SCHEMA_OPTION_STATIC_ENCODING,
+
type=schema_pb2.FieldType(atomic_type=schema_pb2.BOOLEAN),
+ value=schema_pb2.FieldValue(
+ atomic_value=schema_pb2.AtomicTypeValue(
+ boolean=True)))
+ ]))) if has_repr else None
+
Review Comment:

The use of a ternary operator for such a large and complex object
construction significantly hinders readability. It is difficult to see the
condition `if has_repr else None` at the end of this block. Additionally, the
comment about matching `FastPrimitivesCoder` only applies when a representation
is actually provided. It would be much clearer to use a standard `if/else`
block.
```python
if has_repr:
# A portable schema matches FastPrimitivesCoder encoded values
representation = schema_pb2.FieldType(
nullable=False,
row_type=schema_pb2.RowType(
schema=schema_pb2.Schema(
fields=[
schema_pb2.Field(
name=_PYTHON_ANY_FIELD_TYPE_BYTE,
type=schema_pb2.FieldType(
atomic_type=schema_pb2.BYTE, nullable=False)),
schema_pb2.Field(
name=_PYTHON_ANY_FIELD_PAYLOAD,
type=schema_pb2.FieldType(
atomic_type=schema_pb2.BYTES, nullable=False))
],
options=[
schema_pb2.Option(
name=_SCHEMA_OPTION_STATIC_ENCODING,
type=schema_pb2.FieldType(atomic_type=schema_pb2.BOOLEAN),
value=schema_pb2.FieldValue(
atomic_value=schema_pb2.AtomicTypeValue(
boolean=True)))
])))
else:
representation = None
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]