From 311b698041d3bf4a14d1a1c810f21978a5367477 Mon Sep 17 00:00:00 2001 From: Delgan Date: Sat, 7 Dec 2024 15:49:50 +0100 Subject: [PATCH] Add type hints --- setup.py | 1 + src/win32_setctime/_setctime.py | 8 +++++++- src/win32_setctime/py.typed | 0 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/win32_setctime/py.typed diff --git a/setup.py b/setup.py index 1549378..3cd5830 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ version=version, packages=["win32_setctime"], package_dir={"": "src"}, + package_data={"win32_setctime": ["py.typed"]}, description="A small Python utility to set file creation time on Windows", long_description=readme, long_description_content_type="text/markdown", diff --git a/src/win32_setctime/_setctime.py b/src/win32_setctime/_setctime.py index ecd57a0..a11ede1 100644 --- a/src/win32_setctime/_setctime.py +++ b/src/win32_setctime/_setctime.py @@ -1,4 +1,5 @@ import os +import sys try: from ctypes import byref, get_last_error, wintypes, FormatError, WinDLL, WinError @@ -36,7 +37,12 @@ SUPPORTED = os.name == "nt" -def setctime(filepath, timestamp, *, follow_symlinks=True): +from typing import Union + + +def setctime( + filepath: Union[str, os.PathLike[str]], timestamp: float, *, follow_symlinks: bool = True +) -> None: """Set the "ctime" (creation time) attribute of a file given an unix timestamp (Windows only).""" if not SUPPORTED: raise OSError("This function is only available for the Windows platform.") diff --git a/src/win32_setctime/py.typed b/src/win32_setctime/py.typed new file mode 100644 index 0000000..e69de29