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
`imp` module is deprecated in Python 3.4 and removed in Python3.12. This replacement will help with extending Superset support for Python3.12 in the future

Signed-off-by: hainenber <[email protected]>
  • Loading branch information
hainenber committed Dec 26, 2024
1 parent a193d79 commit 6ad9f38
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 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
import importlib.util
from contextlib import contextmanager
from typing import Any, Union, Optional
from unittest.mock import Mock, patch, MagicMock
Expand Down Expand Up @@ -256,10 +256,10 @@ 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
spec = importlib.util.find_spec(module_name)
return spec is not None
except ImportError:
return False

Expand Down

0 comments on commit 6ad9f38

Please sign in to comment.