Skip to content
Open
Changes from all commits
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
26 changes: 13 additions & 13 deletions python-package/xgboost/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def get_model_categories(


def pick_ref_categories(
X: Any,
X: ArrayLike,
model_cats: Optional[Union[FeatureTypes, Categories]],
Xy_cats: Optional[Categories],
) -> Optional[Union[FeatureTypes, Categories]]:
Expand Down Expand Up @@ -682,18 +682,18 @@ def pick_ref_categories(
def _wrap_evaluation_matrices(
*,
missing: float,
X: Any,
y: Any,
group: Optional[Any],
qid: Optional[Any],
sample_weight: Optional[Any],
base_margin: Optional[Any],
X: ArrayLike,
y: ArrayLike,
group: Optional[ArrayLike],
qid: Optional[ArrayLike],
sample_weight: Optional[ArrayLike],
base_margin: Optional[ArrayLike],
feature_weights: Optional[ArrayLike],
eval_set: Optional[Sequence[Tuple[Any, Any]]],
sample_weight_eval_set: Optional[Sequence[Any]],
base_margin_eval_set: Optional[Sequence[Any]],
eval_group: Optional[Sequence[Any]],
eval_qid: Optional[Sequence[Any]],
eval_set: Optional[Sequence[Tuple[ArrayLike, ArrayLike]]],
sample_weight_eval_set: Optional[Sequence[ArrayLike]],
base_margin_eval_set: Optional[Sequence[ArrayLike]],
eval_group: Optional[Sequence[ArrayLike]],
eval_qid: Optional[Sequence[ArrayLike]],
create_dmatrix: Callable,
enable_categorical: bool,
feature_types: Optional[Union[FeatureTypes, Categories]],
Expand Down Expand Up @@ -1209,7 +1209,7 @@ def custom_metric(m: Callable) -> Metric:
wrapped = _metric_decorator(m)
return wrapped

def invalid_type(m: Any) -> None:
def invalid_type(m: object) -> None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object is the proper top type in Python — it means "accepts anything" while keeping type safety. Any disables type checking entirely (both co- and contra-variant), so mypy silently skips any misuse. Since invalid_type only calls type(m), which works on every object, object is the accurate annotation.

That said, this is a minor stylistic point — happy to revert if you prefer keeping Any here.

msg = f"Invalid type for the `eval_metric`: {type(m)}"
raise TypeError(msg)

Expand Down
Loading