Skip to content

Commit 105aa42

Browse files
authored
Fix with the latest mypy. (dmlc#11211)
* Fix with the latest mypy. * conflict with isort and black.
1 parent 7103baf commit 105aa42

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

python-package/xgboost/dask/__init__.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -536,19 +536,16 @@ async def map_worker_partitions(
536536
else:
537537
args.append(ref)
538538

539-
@wraps(func)
540-
def fn(
541-
*args: _P.args, address: str = addr, **kwargs: _P.kwargs
542-
) -> List[_MapRetT]:
543-
# Turn result into a list for bag construction
539+
def fn(_address: str, *args: _P.args, **kwargs: _P.kwargs) -> List[_MapRetT]:
544540
worker = distributed.get_worker()
545541

546-
if worker.address != address:
542+
if worker.address != _address:
547543
raise ValueError(
548-
f"Invalid worker address: {worker.address}, expecting {address}. "
544+
f"Invalid worker address: {worker.address}, expecting {_address}. "
549545
"This is likely caused by one of the workers died and Dask "
550546
"re-scheduled a different one. Resilience is not yet supported."
551547
)
548+
# Turn result into a list for bag construction
552549
return [func(*args, **kwargs)]
553550

554551
# XGBoost requires all workers running training tasks to be unique. Meaning, we
@@ -568,9 +565,8 @@ def fn(
568565
# relax the constraint and prevent Dask from choosing an invalid worker, the
569566
# task will simply hangs. We prefer a quick error here.
570567
#
571-
572568
fut = client.submit(
573-
fn,
569+
update_wrapper(partial(fn, addr), fn),
574570
*args,
575571
pure=False,
576572
workers=[addr],

python-package/xgboost/spark/summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class XGBoostTrainingSummary:
1616

1717
@staticmethod
1818
def from_metrics(
19-
metrics: Dict[str, Dict[str, List[float]]]
19+
metrics: Dict[str, Dict[str, List[float]]],
2020
) -> "XGBoostTrainingSummary":
2121
"""
2222
Create an XGBoostTrainingSummary instance from a nested dictionary of metrics.

0 commit comments

Comments
 (0)