Skip to content

Commit 6593955

Browse files
committed
fix pylint E1120 error.
1 parent 3bdf8ee commit 6593955

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lightning/pytorch/utilities/model_helpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import inspect
1616
import logging
1717
import os
18-
from typing import TYPE_CHECKING, Any, Callable, Generic, Optional, TypeVar
18+
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar
1919

2020
from lightning_utilities.core.imports import RequirementCache
2121
from torch import nn
@@ -104,14 +104,15 @@ 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, _R_co, _P]):
107+
class _restricted_classmethod_impl(classmethod):
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

111111
def __init__(self, method: Callable[Concatenate[type[_T], _P], _R_co]) -> None:
112+
super().__init__(method)
112113
self.method = method
113114

114-
def __get__(self, instance: Optional[_T], cls: type[_T]) -> Callable[_P, _R_co]:
115+
def __get__(self, instance: Optional[_T], cls: type[_T] | None = None) -> Callable[_P, _R_co]:
115116
# The wrapper ensures that the method can be inspected, but not called on an instance
116117
@functools.wraps(self.method)
117118
def wrapper(*args: Any, **kwargs: Any) -> _R_co:

0 commit comments

Comments
 (0)