Skip to content

Commit

Permalink
chore: move constants import earlier/global
Browse files Browse the repository at this point in the history
Import the 'constants' module earlier in a global context: this way more
things can be added to it later.

There should be no behaviour changes.

Signed-off-by: Pino Toscano <[email protected]>
  • Loading branch information
ptoscano committed Jan 31, 2025
1 parent d215935 commit a32978a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/insights_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@

from distutils.version import LooseVersion

try:
from .constants import InsightsConstants
except ImportError:
# The source file is build from 'constants.py.in' and is not
# available during development
class InsightsConstants(object):
version = "development"


LOG_FORMAT = "%(asctime)s %(levelname)8s %(name)s:%(lineno)s %(message)s"
NO_COLOR = os.environ.get("NO_COLOR") is not None
Expand Down Expand Up @@ -448,14 +456,6 @@ def _main():
sys.exit("Unable to load Insights Config")

if config["version"]:
try:
from insights_client.constants import InsightsConstants
except ImportError:
# The source file is build from 'constants.py.in' and is not
# available during development
class InsightsConstants(object):
version = "development"

print("Client: %s" % InsightsConstants.version)
print("Core: %s" % InsightsClient().version())
return
Expand Down

0 comments on commit a32978a

Please sign in to comment.