From e6d22f2b2030b388c6e0bb8327f043b321215a4c Mon Sep 17 00:00:00 2001 From: Alex <100605452+Likio3000@users.noreply.github.com> Date: Mon, 1 Sep 2025 22:09:21 +0200 Subject: [PATCH] Handle pyperclip import warning at runtime --- sc2.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sc2.py b/sc2.py index da290af..7136e56 100644 --- a/sc2.py +++ b/sc2.py @@ -11,11 +11,12 @@ from pathlib import Path # ---------- optional deps ---------- # +PYPERCLIP_WARNING: str | None = None try: import pyperclip # type: ignore except ImportError: pyperclip = None - print( + PYPERCLIP_WARNING = ( "Note: Clipboard functionality ('pyperclip') is not available. Install it with 'uv add pyperclip'." ) @@ -208,6 +209,9 @@ def main() -> None: ) ns = ap.parse_args() + if PYPERCLIP_WARNING and not ns.write: + print(PYPERCLIP_WARNING) + if not ns.tests: EXCLUDED_DIRS.add("tests")