Skip to content

Commit

Permalink
not calling schemas (#5641)
Browse files Browse the repository at this point in the history
* not calling schemas

* Update public/pathway/python/pathway/internals/schema.py

Co-authored-by: Michał Bartoszkiewicz <[email protected]>

* import

---------

Co-authored-by: Michał Bartoszkiewicz <[email protected]>
GitOrigin-RevId: 48b344f718a691fcb23fe0fd3a237e361e69131a
  • Loading branch information
2 people authored and Manul from Pathway committed Feb 8, 2024
1 parent 4c4c94b commit 1f40e26
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/pathway/internals/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from os import PathLike
from pydoc import locate
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, get_type_hints
from typing import TYPE_CHECKING, Any, NoReturn, get_type_hints
from warnings import warn

import numpy as np
Expand Down Expand Up @@ -270,6 +270,11 @@ def __init__(self, *args, append_only: bool | None = None, **kwargs) -> None:
}
self.__types__ = {k: v.typehint for k, v in self.__dtypes__.items()}

def __call__(self) -> NoReturn:
raise TypeError(
"Schemas should not be called. Use `table.schema` not `table.schema()."
)

def __or__(self, other: type[Schema]) -> type[Schema]: # type: ignore
return schema_add(self, other) # type: ignore

Expand Down
10 changes: 10 additions & 0 deletions python/pathway/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,13 @@ class D(pw.Schema, append_only=True):
pass

assert D.universe_properties.append_only is True


def test_schemas_not_to_be_called():
with pytest.raises(TypeError):
pw.Table.empty().schema()


def test_advanced_schemas_not_to_be_called():
with pytest.raises(TypeError):
(pw.Table.empty().schema | pw.Table.empty().schema)()

0 comments on commit 1f40e26

Please sign in to comment.