Skip to content

Commit bc6500a

Browse files
authored
Merge branch 'master' into auto-fix-rules
2 parents 4634473 + e0e42a0 commit bc6500a

File tree

11 files changed

+31
-21
lines changed

11 files changed

+31
-21
lines changed

.github/workflows/_legacy-checkpoints.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- uses: actions/checkout@v5
5959

6060
- name: Install uv and set Python version
61-
uses: astral-sh/setup-uv@v6
61+
uses: astral-sh/setup-uv@v7
6262
with:
6363
python-version: "3.9"
6464
# TODO: Avoid activating environment like this

.github/workflows/ci-tests-fabric.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
- uses: actions/checkout@v5
7272

7373
- name: Install uv and set Python version
74-
uses: astral-sh/setup-uv@v6
74+
uses: astral-sh/setup-uv@v7
7575
with:
7676
python-version: ${{ matrix.config.python-version || '3.9' }}
7777
# TODO: Avoid activating environment like this

.github/workflows/ci-tests-pytorch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
- uses: actions/checkout@v5
7777

7878
- name: Install uv and set Python version
79-
uses: astral-sh/setup-uv@v6
79+
uses: astral-sh/setup-uv@v7
8080
with:
8181
python-version: ${{ matrix.config.python-version || '3.9' }}
8282
# TODO: Avoid activating environment like this

.github/workflows/code-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- uses: actions/checkout@v5
3232

3333
- name: Install uv and set Python version
34-
uses: astral-sh/setup-uv@v6
34+
uses: astral-sh/setup-uv@v7
3535
with:
3636
python-version: "3.11"
3737
# TODO: Avoid activating environment like this

.github/workflows/docs-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
lfs: ${{ matrix.pkg-name == 'pytorch' }}
7474

7575
- name: Install uv and set Python version
76-
uses: astral-sh/setup-uv@v6
76+
uses: astral-sh/setup-uv@v7
7777
with:
7878
python-version: "3.10"
7979
# TODO: Avoid activating environment like this

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ci:
2323

2424
repos:
2525
- repo: https://github.com/pre-commit/pre-commit-hooks
26-
rev: v5.0.0
26+
rev: v6.0.0
2727
hooks:
2828
- id: end-of-file-fixer
2929
- id: trailing-whitespace
@@ -69,7 +69,7 @@ repos:
6969
- id: sphinx-lint
7070

7171
- repo: https://github.com/astral-sh/ruff-pre-commit
72-
rev: v0.12.2
72+
rev: v0.13.3
7373
hooks:
7474
# try to fix what is possible
7575
- id: ruff
@@ -94,8 +94,8 @@ repos:
9494
README.md
9595
)$
9696
97-
- repo: https://github.com/pre-commit/mirrors-prettier
98-
rev: v3.1.0
97+
- repo: https://github.com/JoC0de/pre-commit-prettier
98+
rev: v3.6.2
9999
hooks:
100100
- id: prettier
101101
# https://prettier.io/docs/en/options.html#print-width

requirements/fabric/test.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
coverage ==7.10.6
1+
coverage ==7.10.7
22
numpy >=1.21.0, <1.27.0
33
pytest ==8.4.2
44
pytest-cov ==6.3.0
55
pytest-timeout ==2.4.0
6-
pytest-rerunfailures ==16.0.1
6+
pytest-rerunfailures ==16.0.1; python_version < "3.10"
7+
pytest-rerunfailures ==16.1; python_version >= "3.10"
78
pytest-random-order ==1.2.0
89
click ==8.1.8; python_version < "3.11"
910
click ==8.3.0; python_version > "3.10"

requirements/pytorch/test.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
coverage ==7.10.6
1+
coverage ==7.10.7
22
pytest ==8.4.2
33
pytest-cov ==6.3.0
44
pytest-timeout ==2.4.0
5-
pytest-rerunfailures ==16.0.1
5+
pytest-rerunfailures ==16.0.1; python_version < "3.10"
6+
pytest-rerunfailures ==16.1; python_version >= "3.10"
67
pytest-random-order ==1.2.0
78

89
# needed in tests

src/lightning/pytorch/utilities/model_helpers.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from lightning_utilities.core.imports import RequirementCache
2121
from torch import nn
22-
from typing_extensions import Concatenate, ParamSpec
22+
from typing_extensions import Concatenate, ParamSpec, override
2323

2424
import lightning.pytorch as pl
2525

@@ -104,26 +104,32 @@ 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, 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:
114+
super().__init__(method)
112115
self.method = method
113116

114-
def __get__(self, instance: Optional[_T], cls: type[_T]) -> Callable[_P, _R_co]:
117+
@override
118+
def __get__(self, instance: _T, cls: Optional[type[_T]] = None) -> Callable[_P, _R_co]: # type: ignore[override]
115119
# The wrapper ensures that the method can be inspected, but not called on an instance
116120
@functools.wraps(self.method)
117121
def wrapper(*args: Any, **kwargs: Any) -> _R_co:
118122
# Workaround for https://github.com/pytorch/pytorch/issues/67146
119123
is_scripting = any(os.path.join("torch", "jit") in frameinfo.filename for frameinfo in inspect.stack())
124+
cls_type = cls if cls is not None else type(instance)
120125
if instance is not None and not is_scripting:
121126
raise TypeError(
122-
f"The classmethod `{cls.__name__}.{self.method.__name__}` cannot be called on an instance."
127+
f"The classmethod `{cls_type.__name__}.{self.method.__name__}` cannot be called on an instance."
123128
" Please call it on the class type and make sure the return value is used."
124129
)
125-
return self.method(cls, *args, **kwargs)
130+
return self.method(cls_type, *args, **kwargs)
126131

132+
wrapper.__func__ = self.method
127133
return wrapper
128134

129135

tests/tests_pytorch/graveyard/test_precision.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
def test_precision_plugin_renamed_imports():
55
# base class
6+
from lightning.pytorch.plugins.precision.precision_plugin import PrecisionPlugin as PrecisionPlugin0
7+
68
from lightning.pytorch.plugins import PrecisionPlugin as PrecisionPlugin2
79
from lightning.pytorch.plugins.precision import PrecisionPlugin as PrecisionPlugin1
810
from lightning.pytorch.plugins.precision.precision import Precision
9-
from lightning.pytorch.plugins.precision.precision_plugin import PrecisionPlugin as PrecisionPlugin0
1011

1112
assert issubclass(PrecisionPlugin0, Precision)
1213
assert issubclass(PrecisionPlugin1, Precision)

0 commit comments

Comments
 (0)