Skip to content

Commit 0df4c76

Browse files
authored
Add futures annotations int test (#2405)
* Add futures annotations int test * Add integration test for futures annotation --------- Signed-off-by: Will Sackfield <[email protected]>
1 parent 71ad986 commit 0df4c76

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
build:
22
python_version: "3.11"
3+
python_packages:
4+
- pillow==10.0.0
5+
36
predict: "predict.py:Predictor"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# predict.py - This will FAIL with the TypeError
2+
from __future__ import annotations
3+
4+
from cog import BasePredictor, Input, Path
5+
from PIL import Image
6+
7+
class Predictor(BasePredictor):
8+
def predict(
9+
self,
10+
image: Path = Input(description="Input image"),
11+
) -> Path:
12+
"""Simple pass-through prediction that exhibits the bug."""
13+
# This would normally just return the input image
14+
img = Image.open(image)
15+
output_path = Path("/tmp/output.png")
16+
img.save(output_path)
17+
return output_path
705 KB
Loading

test-integration/test_integration/test_predict.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,3 +787,17 @@ def test_predict_glb_file(cog_binary):
787787
timeout=120.0,
788788
)
789789
assert result.returncode == 0
790+
791+
792+
def test_predict_future_annotations(cog_binary):
793+
project_dir = Path(__file__).parent / "fixtures/future-annotations-project"
794+
795+
result = subprocess.run(
796+
[cog_binary, "predict", "--debug", "-i", "image=@some_image.jpg"],
797+
cwd=project_dir,
798+
check=True,
799+
capture_output=True,
800+
text=True,
801+
timeout=120.0,
802+
)
803+
assert result.returncode == 0

0 commit comments

Comments
 (0)