@@ -427,18 +427,15 @@ def _check_environment(environment):
427427 )
428428 # Notes about checking the env keys:
429429 #
430- # - env ⊂ variables: in some cases we could check that there are no extra
431- # keys in `environment`, ie all keys in `environment` correspond to a
432- # name in the DataOp. However in other cases we naturally end up
433- # using a bigger environment than what is needed. For example we want to
434- # evaluate a sub-DataOp (such as the `mark_as_X()` node), and to do
435- # it we use the environment that was passed to evaluate the full
436- # DataOp. So if we want such a verification it should be a separate
437- # check done at a higher level (eg in the estimators' `fit`, `predict`
438- # etc.) where we know we are not working with a sub-DataOp. We do perform
439- # such a check when a key is missing from the env to provide a better
440- # message, but it is only used for the content of the message rather than
441- # enforcing no extra keys ahead of time.
430+ # - env ⊂ variables: we could check that there are no extra keys in
431+ # `environment`, i.e. all keys in `environment` correspond to a name in
432+ # the DataOp. However in some cases we naturally end up using a bigger
433+ # environment than what is needed. For example we want to evaluate a
434+ # sub-DataOp (such as the result of `.skb.find()` or `.skb.find_X_y()`),
435+ # and to do it we use the environment created to evaluate the full
436+ # DataOp. We do perform this check when a key is missing from the env to
437+ # provide a better error message, but it is only used for the content of
438+ # the message rather than enforcing no extra keys ahead of time.
442439 #
443440 # - variables ⊂ env: we cannot check that all variables in the DataOp
444441 # have a matching key in the `environment`, because depending on the
@@ -531,9 +528,11 @@ def _uninitialized_variable_msg(error, data_op, environment):
531528 var_names = list (named_nodes (data_op ).keys ())
532529 choice_names = [n for c in choices (data_op ).values () if (n := c .name ) is not None ]
533530 unused = list (
534- {k for k in environment .keys () if not k .startswith ("_skrub_" )}.difference (
535- var_names + choice_names
536- )
531+ {
532+ k
533+ for k in environment .keys ()
534+ if isinstance (k , str ) and not k .startswith ("_skrub_" )
535+ }.difference (var_names + choice_names )
537536 )
538537
539538 msg = (
0 commit comments