Address remaining mypy errors in python package. (#7914)

This commit is contained in:
Jiaming Yuan
2022-05-18 22:46:15 +08:00
committed by GitHub
parent edf9a9608e
commit f93a727869
6 changed files with 41 additions and 43 deletions

View File

@@ -7,7 +7,6 @@ from typing import Optional
from contextlib import contextmanager
from io import StringIO
from xgboost.compat import SKLEARN_INSTALLED, PANDAS_INSTALLED
from xgboost.compat import DASK_INSTALLED
import pytest
import gc
import xgboost as xgb
@@ -44,8 +43,14 @@ def no_sklearn():
def no_dask():
return {'condition': not DASK_INSTALLED,
'reason': 'Dask is not installed'}
try:
import pkg_resources
pkg_resources.get_distribution("dask")
DASK_INSTALLED = True
except pkg_resources.DistributionNotFound:
DASK_INSTALLED = False
return {"condition": not DASK_INSTALLED, "reason": "Dask is not installed"}
def no_pandas():