Skip to content

Commit ee7fa43

Browse files
TresYapBordalantiga
authored
fix: swapped _R_co and _P to prevent type error. (#20508)
When loading a pytorch-lightning model from MLFlow, I get `TypeError: Type parameter +_R_co without a default follows type parameter with a default`. This happens whenever doing `import pytorch_lightning as pl` which is done by packages like MLFlow. Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com> Co-authored-by: Luca Antiga <luca.antiga@gmail.com>
1 parent efe311c commit ee7fa43

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lightning/pytorch/utilities/model_helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _check_mixed_imports(instance: object) -> None:
104104
_R_co = TypeVar("_R_co", covariant=True) # return type of the decorated method
105105

106106

107-
class _restricted_classmethod_impl(Generic[_T, _P, _R_co]):
107+
class _restricted_classmethod_impl(Generic[_T, _R_co, _P]):
108108
"""Drop-in replacement for @classmethod, but raises an exception when the decorated method is called on an instance
109109
instead of a class type."""
110110

0 commit comments

Comments
 (0)