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>
This commit is contained in:
TresYap 2025-01-07 01:50:51 +08:00 committed by GitHub
parent efe311cd46
commit ee7fa43d2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -104,7 +104,7 @@ _P = ParamSpec("_P") # parameters of the decorated method
_R_co = TypeVar("_R_co", covariant=True) # return type of the decorated method
class _restricted_classmethod_impl(Generic[_T, _P, _R_co]):
class _restricted_classmethod_impl(Generic[_T, _R_co, _P]):
"""Drop-in replacement for @classmethod, but raises an exception when the decorated method is called on an instance
instead of a class type."""