@@ -217,7 +217,7 @@ def _get_dataloader_init_args_and_kwargs(
217
217
else :
218
218
dl_kwargs .update (_dataloader_init_kwargs_resolve_sampler (dataloader , sampler , mode , disallow_batch_sampler ))
219
219
220
- required_args : Union [ list [ str ], set [ str ]] = {
220
+ required_args = {
221
221
p .name
222
222
for p in params .values ()
223
223
if p .kind in (p .POSITIONAL_ONLY , p .POSITIONAL_OR_KEYWORD )
@@ -227,28 +227,28 @@ def _get_dataloader_init_args_and_kwargs(
227
227
}
228
228
# the dataloader has required args which we could not extract from the existing attributes
229
229
if required_args :
230
- required_args = sorted (required_args )
230
+ sorted_required_args = sorted (required_args )
231
231
dataloader_cls_name = dataloader .__class__ .__name__
232
- missing_args_message = ", " .join (f"`self.{ arg_name } `" for arg_name in required_args )
232
+ missing_args_message = ", " .join (f"`self.{ arg_name } `" for arg_name in sorted_required_args )
233
233
raise MisconfigurationException (
234
234
f"Trying to inject custom `Sampler` into the `{ dataloader_cls_name } ` instance. "
235
235
"This would fail as some of the `__init__` arguments are not available as instance attributes. "
236
- f"The missing attributes are { required_args } . If you instantiate your `{ dataloader_cls_name } ` inside a "
237
- "`*_dataloader` hook of your module, we will do this for you."
236
+ f"The missing attributes are { sorted_required_args } . If you instantiate your `{ dataloader_cls_name } ` "
237
+ "inside a `*_dataloader` hook of your module, we will do this for you."
238
238
f" Otherwise, define { missing_args_message } inside your `__init__`."
239
239
)
240
240
241
241
if not has_variadic_kwargs :
242
242
# the dataloader signature does not allow keyword arguments that need to be passed
243
- missing_kwargs : Union [ list [ str ], set [ str ]] = (set (dl_kwargs ) | set (arg_names )) - params .keys ()
243
+ missing_kwargs = (set (dl_kwargs ) | set (arg_names )) - params .keys ()
244
244
if missing_kwargs :
245
- missing_kwargs = sorted (missing_kwargs )
245
+ sorted_missing_kwargs = sorted (missing_kwargs )
246
246
dataloader_cls_name = dataloader .__class__ .__name__
247
247
raise MisconfigurationException (
248
248
f"Trying to inject parameters into the `{ dataloader_cls_name } ` instance. "
249
249
"This would fail as it doesn't expose all its attributes in the `__init__` signature. "
250
- f"The missing arguments are { missing_kwargs } . HINT: If you wrote the `{ dataloader_cls_name } ` class, "
251
- "add the `__init__` arguments or allow passing `**kwargs`"
250
+ f"The missing arguments are { sorted_missing_kwargs } . HINT: If you wrote the `{ dataloader_cls_name } ` "
251
+ "class, add the `__init__` arguments or allow passing `**kwargs`"
252
252
)
253
253
254
254
if _FaultTolerantMode .detect_current_mode ().is_automatic :
0 commit comments