{"record":{"id":"079042d89b53236f","repo":"pathwaycom/pathway","slug":"schemas-should-not-be-called-use-table-schema-n","errorCode":null,"errorMessage":"Schemas should not be called. Use `table.schema` not `table.schema()`.","messagePattern":"Schemas should not be called\\. Use `table\\.schema` not `table\\.schema\\(\\)`\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/schema.py","lineNumber":318,"sourceCode":"        self.__columns__ = _create_column_definitions(self, bases, schema_properties)\n        pk_dtypes = [col.dtype for col in self.__columns__.values() if col.primary_key]\n        if len(pk_dtypes) > 0:\n            derived_type = dt.Pointer(*pk_dtypes)\n            assert id_dtype in [derived_type, dt.ANY_POINTER]\n            id_dtype = derived_type\n        self.__universe_properties__ = _universe_properties(\n            list(self.__columns__.values()),\n            schema_properties,\n            dtype=id_dtype,\n            append_only=id_append_only,\n        )\n        self.__dtypes__ = {\n            name: column.dtype for name, column in self.__columns__.items()\n        }\n        self.__types__ = {k: v.typehint for k, v in self.__dtypes__.items()}\n\n    def __call__(self) -> NoReturn:\n        raise TypeError(\n            \"Schemas should not be called. Use `table.schema` not `table.schema().\"\n        )\n\n    def __or__(self, other: type[Schema]) -> type[Schema]:  # type: ignore\n        return schema_add(self, other)  # type: ignore\n\n    def columns(self) -> Mapping[str, ColumnSchema]:\n        return MappingProxyType(self.__columns__)\n\n    def column_names(self) -> list[str]:\n        return list(self.keys())\n\n    def columns_to_json_serializable_dict(self) -> dict:\n        columns = {}\n        for column_name, column_schema in self.columns().items():\n            columns[column_name] = column_schema.to_json_serializable_dict()\n        return columns\n","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/schema.py#L300-L336","documentation":"pw.Schema metaclass defines __call__ to always raise, because a Schema is a class (type definition), not an instance you construct or call. This guard catches the common mistake of treating table.schema like a method — the schema is a plain attribute in Pathway, unlike older APIs or pandas-style accessors.","triggerScenarios":"Calling table.schema() (with parentheses) instead of using table.schema; also attempting to 'instantiate' a schema class like MySchema() to build an empty table.","commonSituations":"Migrating from Pathway versions or tutorials where schema() was callable; muscle memory from accessor methods; using table.schema().columns instead of table.schema.columns.","solutions":["Use table.schema without parentheses: table.schema.columns(), table.schema.typehints(), etc.","To create a typed empty table use pw.Table.empty(schema=MySchema) (or pw.debug.table_from_markdown for tests), not MySchema()."],"exampleFix":"# before\ncols = table.schema().columns()\n\n# after\ncols = table.schema.columns()","handlingStrategy":"type-guard","validationCode":"import pathway as pw\n\ndef schema_usage_ok(table: pw.Table) -> None:\n    assert not callable(table.schema), \"use table.schema (no parentheses)\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember: table.schema is an attribute in current Pathway; never call it.","Grep your codebase for 'schema()' when migrating from older Pathway versions."],"tags":["pathway","schema","api-misuse","migration"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}