Skip to content

Commit

Permalink
chore: replace imp built-in module usage for future Python3.12 usage (
Browse files Browse the repository at this point in the history
apache#31622)

Signed-off-by: hainenber <[email protected]>
Co-authored-by: Ville Brofeldt <[email protected]>
  • Loading branch information
hainenber and villebro authored Jan 6, 2025
1 parent 109e6c6 commit 5484db3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/integration_tests/base_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""Unit tests for Superset"""

from datetime import datetime
import imp
from importlib.util import find_spec
from contextlib import contextmanager
from typing import Any, Union, Optional
from unittest.mock import Mock, patch, MagicMock
Expand Down Expand Up @@ -256,11 +256,11 @@ def get_table_by_id(table_id: int) -> SqlaTable:
return db.session.query(SqlaTable).filter_by(id=table_id).one()

@staticmethod
def is_module_installed(module_name):
def is_module_installed(module_name: str) -> bool:
try:
imp.find_module(module_name)
return True
except ImportError:
spec = find_spec(module_name)
return spec is not None
except (ModuleNotFoundError, ValueError, TypeError, ImportError):
return False

def get_or_create(self, cls, criteria, **kwargs):
Expand Down

0 comments on commit 5484db3

Please sign in to comment.