Skip to content

Commit

Permalink
fix(backport): Add TYPE_CHECKING guard for numpy.typing (#2213)
Browse files Browse the repository at this point in the history
* Backport PR #2208
  • Loading branch information
matthewfeickert authored May 18, 2023
1 parent 61096c5 commit fe4b43b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[report]
omit =
src/pyhf/typing.py
exclude_also =
if TYPE_CHECKING:
10 changes: 8 additions & 2 deletions src/pyhf/tensor/numpy_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
from __future__ import annotations

import logging
from typing import Callable, Generic, Mapping, Sequence, TypeVar, Union
from typing import TYPE_CHECKING, Callable, Generic, Mapping, Sequence, TypeVar, Union

import numpy as np
from numpy.typing import ArrayLike, DTypeLike, NBitBase, NDArray

# Needed while numpy lower bound is older than v1.21.0
if TYPE_CHECKING:
from numpy.typing import ArrayLike, DTypeLike, NBitBase, NDArray
else:
NBitBase = "NBitBase"

from scipy import special
from scipy.special import gammaln, xlogy
from scipy.stats import norm, poisson
Expand Down

0 comments on commit fe4b43b

Please sign in to comment.