diff --git a/rbc/errors.py b/rbc/errors.py index 9b91b3fb..9e2aed8f 100644 --- a/rbc/errors.py +++ b/rbc/errors.py @@ -3,8 +3,9 @@ """ -from rbc.utils import get_version -from numba.core.errors import TypingError +from numba.core.errors import NumbaTypeError, NumbaNotImplementedError, \ + RequireLiteralValue, TypingError, \ + DeprecationError # noqa: F401 class HeavyDBServerError(Exception): @@ -43,17 +44,3 @@ class ForbiddenIntrinsicError(Exception): https://github.com/xnd-project/rbc/issues/207 """ pass - - -if get_version('numba') < (0, 55): - class NumbaTypeError(TypingError): - pass - - class NumbaNotImplementedError(TypingError): - pass - - class RequireLiteralValue(TypingError): - pass -else: - from numba.core.errors import NumbaTypeError, NumbaNotImplementedError, \ - RequireLiteralValue # noqa: F401 diff --git a/rbc/external.py b/rbc/external.py index 853c7c43..bad810a1 100644 --- a/rbc/external.py +++ b/rbc/external.py @@ -2,12 +2,11 @@ """ # This code has heavily inspired in the numba.extending.intrisic code -import warnings from typing import List, Union from numba.core import extending, funcdesc, types, typing from rbc.typesystem import Type from rbc.targetinfo import TargetInfo -from rbc.errors import UnsupportedError +from rbc.errors import UnsupportedError, DeprecationError from rbc.utils import validate_devices @@ -44,7 +43,7 @@ def external(cls, signature, *, devices=['CPU']): annotation_devices = validate_devices([d for d in t.annotation() if d.upper() in {'CPU', 'GPU'}]) for d in annotation_devices: - warnings.warn( + raise DeprecationError( f'Signature {signature} uses deprecated device annotation (`|{d}`).' ' Use `devices` kw argument to specify the supported devices of the' f' external function `{name}`') diff --git a/rbc/tests/heavydb/test_external.py b/rbc/tests/heavydb/test_external.py index 5ca15acb..afec5ad8 100644 --- a/rbc/tests/heavydb/test_external.py +++ b/rbc/tests/heavydb/test_external.py @@ -1,6 +1,7 @@ import pytest from rbc.tests import heavydb_fixture from rbc.external import external +from rbc.errors import DeprecationError from numba import types @@ -59,3 +60,9 @@ def test_log2(a): _, result = heavydb.sql_execute("select test_log2(8.0)") assert list(result) == [(3.0,)] + + +def test_deprecated_device_annotation(): + msg = r".* uses deprecated device annotation .*" + with pytest.raises(DeprecationError, match=msg): + _ = external('float64 cos(float64)|CPU')