Skip to content

Commit 0c931e8

Browse files
committed
fix: Typings
1 parent e414eba commit 0c931e8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/c2pa/c2pa.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ def add_ingredient_from_stream(
17731773
format: str,
17741774
source: Any):
17751775
"""Add an ingredient from a stream to the builder.
1776-
Explicitly named API requiring a stream.
1776+
Explicitly named API requiring a stream as input parameter.
17771777
17781778
Args:
17791779
ingredient_json: The JSON ingredient definition
@@ -1810,9 +1810,9 @@ def add_ingredient_from_file_path(
18101810
self,
18111811
ingredient_json: str,
18121812
format: str,
1813-
filepath: str):
1813+
filepath: Union[str, Path]):
18141814
"""Add an ingredient from a file path to the builder.
1815-
THis is a legacy method.
1815+
This is a legacy method.
18161816
18171817
.. deprecated:: 0.13.0
18181818
This method is deprecated and will be removed in a future version.
@@ -1821,7 +1821,7 @@ def add_ingredient_from_file_path(
18211821
Args:
18221822
ingredient_json: The JSON ingredient definition
18231823
format: The MIME type or extension of the ingredient
1824-
filepath: The path to the file containing the ingredient data
1824+
filepath: The path to the file containing the ingredient data (can be a string or Path object)
18251825
18261826
Raises:
18271827
C2paError: If there was an error adding the ingredient
@@ -1836,8 +1836,11 @@ def add_ingredient_from_file_path(
18361836
)
18371837

18381838
try:
1839+
# Convert Path object to string if necessary
1840+
filepath_str = str(filepath)
1841+
18391842
# Does the stream handling to use add_ingredient_from_stream
1840-
with open(filepath, 'rb') as file_stream:
1843+
with open(filepath_str, 'rb') as file_stream:
18411844
self.add_ingredient_from_stream(ingredient_json, format, file_stream)
18421845
except FileNotFoundError:
18431846
raise FileNotFoundError(f"File not found: {filepath}")

0 commit comments

Comments
 (0)