Skip to content

Commit

Permalink
Revert: Validate scale is not too big
Browse files Browse the repository at this point in the history
Scale can be larger than precision
  • Loading branch information
faph committed Nov 6, 2023
1 parent 1057659 commit 85c36be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
9 changes: 2 additions & 7 deletions src/py_avro_schema/_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,8 @@ def _size(cls, py_type: Type) -> Tuple[int, int]:

@staticmethod
def _validate_size_tuple(tuple_: Tuple) -> bool:
"""
Checks whether a given tuple is a tuple of (precision, scale)
Must be integers.
Scale must not be greater than precision
"""
return len(tuple_) == 2 and all(isinstance(item, int) for item in tuple_) and tuple_[0] >= tuple_[1]
"""Checks whether a given tuple is a tuple of (precision, scale)"""
return len(tuple_) == 2 and all(isinstance(item, int) for item in tuple_)

def data(self, names: NamesType) -> JSONObj:
"""Return the schema data"""
Expand Down
6 changes: 0 additions & 6 deletions tests/test_logicals.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ def test_annotated_decimal_neg_scale():
assert_schema(py_type, expected)


def test_annotated_decimal_scale_too_big():
py_type = Annotated[decimal.Decimal, (5, 6)]
with pytest.raises(pas.TypeNotSupportedError):
assert_schema(py_type, {})


def test_annotated_decimal_no_tuple():
py_type = Annotated[decimal.Decimal, ...]
with pytest.raises(pas.TypeNotSupportedError):
Expand Down

0 comments on commit 85c36be

Please sign in to comment.