pathwaycom/pathway · error · ValueError
definitions of columns {names} lack type annotation
Error message
definitions of columns {names} lack type annotation What it means
After schema building consumes all annotated columns, any leftover entries in the fields dict are class attributes that were assigned a column_definition (or inherited one) but received no type annotation. Pathway requires every column definition to be paired with an annotation so the dtype is unambiguous, so leftovers raise this ValueError listing the offending names.
Source
Thrown at python/pathway/internals/schema.py:256
+ f" value {schema_property!r} but column"
+ f" `{column_name}` got {column_property!r}"
)
return column_property
columns[column_name] = ColumnSchema(
primary_key=column.primary_key,
default_value=column.default_value,
dtype=dt.wrap(dtype),
name=column_name,
append_only=_get_column_property("append_only", False),
description=column.description,
example=column.example,
source_component=column.source_component,
)
if fields:
names = ", ".join(fields.keys())
raise ValueError(f"definitions of columns {names} lack type annotation")
return columns
def _universe_properties(
columns: list[ColumnSchema],
schema_properties: SchemaProperties,
dtype: dt.DType,
append_only: bool | None = None,
) -> ColumnProperties:
if append_only is None:
append_only = False
if len(columns) > 0:
append_only = any(c.append_only for c in columns)
elif schema_properties.append_only is not None:
append_only = schema_properties.append_only
return ColumnProperties(dtype=dtype, append_only=append_only)
View on GitHub (pinned to fa2f74a464)
Solutions
- Add a type annotation to every column attribute: name: str = pw.column_definition(...).
- If the attribute is not meant to be a column, rename it or remove the column_definition assignment.
- When subclassing an existing schema, annotate overridden columns again.
Example fix
# before
class S(pw.Schema):
name = pw.column_definition(dtype=str)
# after
class S(pw.Schema):
name: str = pw.column_definition(dtype=str) Defensive patterns
Strategy: type-guard
Validate before calling
import inspect
from pathway.internals.schema import ColumnDefinition
def all_definitions_annotated(cls) -> bool:
ann = inspect.getannotations(cls)
return all(
name in ann
for name, v in vars(cls).items()
if isinstance(v, ColumnDefinition)
) Prevention
- Always pair 'name: <type> = column_definition(...)' — annotation is mandatory.
- Enable mypy with disallow_untyped_defs on schema modules to catch bare assignments.
When it happens
Trigger: class S(pw.Schema): name = pw.column_definition(dtype=str) — missing the 'name: str' annotation. Also inheriting __columns__ from a base schema but reassigning a definition without re-annotating.
Common situations: Writing attribute-only style (as in dataclasses without annotations); refactoring a schema and dropping annotations while keeping definitions.
Related errors
- `{column_name}` should be a column definition, found {type(c
- type annotation of column `{column_name}` does not match col
- Failed to detect the region of S3 bucket {bucket!r} (HTTP st
- SchemaRegistryHeader.value must be a str, got {type(self.val
- argument {name} has incorrect schema
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/351a548082ba1b7b.
Report an issue: GitHub.