Skip to content

Commit 2e0f6db

Browse files
author
otaj
committed
parity with lightning_lite
1 parent a31ed67 commit 2e0f6db

File tree

1 file changed

+9
-9
lines changed
  • src/pytorch_lightning/utilities

1 file changed

+9
-9
lines changed

src/pytorch_lightning/utilities/data.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def _get_dataloader_init_args_and_kwargs(
217217
else:
218218
dl_kwargs.update(_dataloader_init_kwargs_resolve_sampler(dataloader, sampler, mode, disallow_batch_sampler))
219219

220-
required_args: Union[list[str], set[str]] = {
220+
required_args = {
221221
p.name
222222
for p in params.values()
223223
if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD)
@@ -227,28 +227,28 @@ def _get_dataloader_init_args_and_kwargs(
227227
}
228228
# the dataloader has required args which we could not extract from the existing attributes
229229
if required_args:
230-
required_args = sorted(required_args)
230+
sorted_required_args = sorted(required_args)
231231
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)
233233
raise MisconfigurationException(
234234
f"Trying to inject custom `Sampler` into the `{dataloader_cls_name}` instance. "
235235
"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."
238238
f" Otherwise, define {missing_args_message} inside your `__init__`."
239239
)
240240

241241
if not has_variadic_kwargs:
242242
# 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()
244244
if missing_kwargs:
245-
missing_kwargs = sorted(missing_kwargs)
245+
sorted_missing_kwargs = sorted(missing_kwargs)
246246
dataloader_cls_name = dataloader.__class__.__name__
247247
raise MisconfigurationException(
248248
f"Trying to inject parameters into the `{dataloader_cls_name}` instance. "
249249
"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`"
252252
)
253253

254254
if _FaultTolerantMode.detect_current_mode().is_automatic:

0 commit comments

Comments
 (0)