From dd6fa027b639a08d1af40a616c55350f82689c92 Mon Sep 17 00:00:00 2001 From: Richard Lawson Date: Wed, 14 Dec 2022 18:13:43 -0500 Subject: [PATCH] fix: Premature imports of optional packages (#508) --- explorer/charts.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/explorer/charts.py b/explorer/charts.py index 218a7f5c..910010c5 100644 --- a/explorer/charts.py +++ b/explorer/charts.py @@ -3,15 +3,15 @@ from django.core.exceptions import ImproperlyConfigured +from explorer import app_settings -try: - import matplotlib.pyplot as plt - import seaborn as sns - from matplotlib.figure import Figure -except ImportError: - from . import app_settings - if app_settings.EXPLORER_CHARTS_ENABLED: +if app_settings.EXPLORER_CHARTS_ENABLED: + try: + import matplotlib.pyplot as plt + import seaborn as sns + from matplotlib.figure import Figure + except ImportError: raise ImproperlyConfigured( "If `EXPLORER_CHARTS_ENABLED` is enabled, `matplotlib` and `seaborn` must be installed.")