From ace8de363b031f9fa31657bff9017c2afd60938b Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Sat, 18 Dec 2021 10:50:46 -0500 Subject: Fix RuntimeWarning when using the -m flag Signed-off-by: Matthew Peveler --- asciidoc/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/asciidoc/__init__.py b/asciidoc/__init__.py index 15f6aa7..884b29e 100644 --- a/asciidoc/__init__.py +++ b/asciidoc/__init__.py @@ -1,7 +1,13 @@ """asciidoc module""" -from .api import AsciiDocAPI -from .asciidoc import execute, cli +import sys from .__metadata__ import VERSION, __version__ -__all__ = ['AsciiDocAPI', 'execute', 'cli', 'VERSION', '__version__'] +__all__ = ['VERSION', '__version__'] + +# If running as a script, we avoid these imports to avoid a circular +# RuntimeWarning, which is fine as we don't use them in that case. +if "-m" not in sys.argv: + from .api import AsciiDocAPI + from .asciidoc import execute, cli + __all__ += ['AsciiDocAPI', 'execute', 'cli'] -- cgit v1.2.1