summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/click/utils.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/click/utils.py b/src/click/utils.py
index 467b7b6..8283788 100644
--- a/src/click/utils.py
+++ b/src/click/utils.py
@@ -475,7 +475,7 @@ class PacifyFlushWrapper:
def _detect_program_name(
- path: t.Optional[str] = None, _main: ModuleType = sys.modules["__main__"]
+ path: t.Optional[str] = None, _main: t.Optional[ModuleType] = None
) -> str:
"""Determine the command used to run the program, for use in help
text. If a file or entry point was executed, the file name is
@@ -497,6 +497,9 @@ def _detect_program_name(
:meta private:
"""
+ if _main is None:
+ _main = sys.modules["__main__"]
+
if not path:
path = sys.argv[0]