Skip to content

Commit

Permalink
Merge pull request #1 from radarhere/bug/compat/numpy1.20
Browse files Browse the repository at this point in the history
Do not import numpy.typing unless TYPE_CHECKING
  • Loading branch information
neutrinoceros committed Jul 2, 2024
2 parents b4ee967 + 8b8fc18 commit ce6fb12
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/PIL/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import os
import sys
from typing import Any, Protocol, Sequence, TypeVar, Union
from typing import TYPE_CHECKING, Any, Protocol, Sequence, TypeVar, Union

Check warning on line 5 in src/PIL/_typing.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/_typing.py#L5

Added line #L5 was not covered by tests

try:
import numpy.typing as npt
if TYPE_CHECKING:
try:
import numpy.typing as npt

NumpyArray = npt.NDArray[Any] # requires numpy>=1.21
except (ImportError, AttributeError):
pass
NumpyArray = npt.NDArray[Any] # requires numpy>=1.21
except (ImportError, AttributeError):
pass

if sys.version_info >= (3, 10):
from typing import TypeGuard
Expand Down

0 comments on commit ce6fb12

Please sign in to comment.