From 5c2dd96a69a935cf45acbdf2ffabbd39b27d38fa Mon Sep 17 00:00:00 2001 From: Chuck Wooters Date: Mon, 29 Oct 2018 03:10:32 -0700 Subject: [PATCH] patch main to ensure click_patch() gets called (#572) --- README.md | 1 + black.py | 6 +++++- blackd.py | 6 +++++- setup.py | 7 ++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index afb160e..a255022 100644 --- a/README.md +++ b/README.md @@ -1351,3 +1351,4 @@ Multiple contributions by: * [Stavros Korokithakis](mailto:hi@stavros.io) * [Sunil Kapil](mailto:snlkapil@gmail.com) * [Vishwas B Sharma](mailto:sharma.vishwas88@gmail.com) +* [Chuck Wooters](mailto:chuck.wooters@microsoft.com) diff --git a/black.py b/black.py index d060820..4d85865 100644 --- a/black.py +++ b/black.py @@ -3662,6 +3662,10 @@ def patch_click() -> None: module._verify_python3_env = lambda: None -if __name__ == "__main__": +def patched_main() -> None: patch_click() main() + + +if __name__ == "__main__": + patched_main() diff --git a/blackd.py b/blackd.py index 50614d0..e1006a1 100644 --- a/blackd.py +++ b/blackd.py @@ -108,6 +108,10 @@ async def handle(request: web.Request, executor: Executor) -> web.Response: return web.Response(status=500, text=str(e)) -if __name__ == "__main__": +def patched_main() -> None: black.patch_click() main() + + +if __name__ == "__main__": + patched_main() diff --git a/setup.py b/setup.py index 87583ca..096be9e 100644 --- a/setup.py +++ b/setup.py @@ -57,5 +57,10 @@ setup( "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance", ], - entry_points={"console_scripts": ["black=black:main", "blackd=blackd:main [d]"]}, + entry_points={ + "console_scripts": [ + "black=black:patched_main", + "blackd=blackd:patched_main [d]", + ] + }, ) -- 2.39.5