Skip to content

chore: replace imp built-in module usage for future Python3.12 usage #31622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading