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

fix: Add TYPE_CHECKING guard for numpy.typing #2208

Merged
merged 5 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ omit = ["*/pyhf/typing.py"]
precision = 1
sort = "cover"
show_missing = true
exclude_also = [
"if TYPE_CHECKING:"
]

[tool.mypy]
files = "src"
Expand Down
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:
matthewfeickert marked this conversation as resolved.
Show resolved Hide resolved
from numpy.typing import ArrayLike, DTypeLike, NBitBase, NDArray
else:
NBitBase = "NBitBase"

kratsg marked this conversation as resolved.
Show resolved Hide resolved
from scipy import special
from scipy.special import gammaln, xlogy
from scipy.stats import norm, poisson
Expand Down