Skip to content

Commit 2e7c1a3

Browse files
authored
fix: support async entry point (#85)
The project's `project.scripts` entry otherwise would fail since the coroutine was not awaited.
1 parent a6e2fa4 commit 2e7c1a3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/git_draft/__main__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def edit(*, path: Path | None = None, text: str | None = None) -> str:
152152
_PROMPT_PLACEHOLDER = "Enter your prompt here..."
153153

154154

155-
async def main() -> None: # noqa: PLR0912 PLR0915
155+
async def run() -> None: # noqa: PLR0912 PLR0915
156156
config = Config.load()
157157
(opts, args) = new_parser().parse_args()
158158

@@ -230,10 +230,14 @@ async def main() -> None: # noqa: PLR0912 PLR0915
230230
raise UnreachableError()
231231

232232

233-
if __name__ == "__main__":
233+
def main() -> None:
234234
try:
235-
asyncio.run(main())
235+
asyncio.run(run())
236236
except Exception as err:
237237
_logger.exception("Program failed.")
238238
print(f"Error: {err}", file=sys.stderr)
239239
sys.exit(1)
240+
241+
242+
if __name__ == "__main__":
243+
main()

0 commit comments

Comments
 (0)