chore: use contextlib.surpress instead of passing on error (#24896)

Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
This commit is contained in:
Sebastian Liebscher
2023-08-29 18:09:01 +02:00
committed by GitHub
parent 72150ebadf
commit e585db85b6
18 changed files with 66 additions and 146 deletions

View File

@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import contextlib
import re
import threading
from re import Pattern
@@ -24,8 +25,7 @@ from flask_babel import gettext as __
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy.orm import Session
# Need to try-catch here because pyocient may not be installed
try:
with contextlib.suppress(ImportError, RuntimeError): # pyocient may not be installed
# Ensure pyocient inherits Superset's logging level
import geojson
import pyocient
@@ -35,8 +35,6 @@ try:
superset_log_level = app.config["LOG_LEVEL"]
pyocient.logger.setLevel(superset_log_level)
except (ImportError, RuntimeError):
pass
from superset.constants import TimeGrain
from superset.db_engine_specs.base import BaseEngineSpec