Skip to content

Commit e3e5c12

Browse files
committed
ignore mypy error.
1 parent 58d3f4d commit e3e5c12

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/lightning/pytorch/utilities/model_helpers.py

Lines changed: 5 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, Optional, TypeVar
18+
from typing import TYPE_CHECKING, Any, Callable, Generic, Optional, TypeVar
1919

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

111+
method: Callable[Concatenate[type[_T], _P], _R_co]
112+
111113
def __init__(self, method: Callable[Concatenate[type[_T], _P], _R_co]) -> None:
112114
super().__init__(method)
113115
self.method = method
114116

115117
@override
116-
def __get__(self, instance: Optional[_T], cls: Optional[type[_T]] = None) -> Callable[_P, _R_co]:
118+
def __get__(self, instance: _T, cls: Optional[type[_T]] = None) -> Callable[_P, _R_co]: # type: ignore[override]
117119
# The wrapper ensures that the method can be inspected, but not called on an instance
118120
@functools.wraps(self.method)
119121
def wrapper(*args: Any, **kwargs: Any) -> _R_co:

0 commit comments

Comments
 (0)