Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for numba and with typeguard #268

Open
gatoniel opened this issue Feb 6, 2023 · 2 comments
Open

Add tests for numba and with typeguard #268

gatoniel opened this issue Feb 6, 2023 · 2 comments

Comments

@gatoniel
Copy link
Owner

gatoniel commented Feb 6, 2023

This issue agronholm/typeguard#277 is solved now. Test and incorporate.

@gatoniel
Copy link
Owner Author

gatoniel commented Mar 1, 2023

This is currently still not working as typeguard is not yet released on pypi and nox_poetry has some issues with installing from github...

However, it is unclear whether version 3.0.0rc1 seems to solve the issue. Using the file test.py with

from typing import TypeVar

import numpy as np
import numpy.typing as npt
from numba import njit
from typeguard import typechecked

T = TypeVar("T", bound=np.generic)


@typechecked
@njit
def numba_sum(
    array: npt.NDArray[T],
) -> T:
    return np.sum(array)


x = np.arange(4)
s = numba_sum.py_func(x)
s = numba_sum(x)

and running the command poetry run python test.py gives the warning

/home/niklas/.cache/pypoetry/virtualenvs/merge-stardist-masks-Mk5qjuGF-py3.9/lib/python3.9/site-packages/typeguard/_decorators.py:170: InstrumentationWarning: Cannot instrument __main__.numba_sum -- @typechecked only supports instrumenting functions wrapped with @classmethod, @staticmethod or @property
  warn(

Using nox -s typeguard -p 3.9 gives several errors.

@gatoniel
Copy link
Owner Author

gatoniel commented Mar 1, 2023

I asked for help here: agronholm/typeguard#306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant