Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit suggestions #226

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ repos:
args: ["--in-place"]

- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.1.1
hooks:
- id: black
name: Black code
Expand All @@ -59,7 +59,7 @@ repos:
exclude: CHANGELOG.md

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
rev: v4.0.0-alpha.8
Borda marked this conversation as resolved.
Show resolved Hide resolved
hooks:
- id: prettier
# https://prettier.io/docs/en/options.html#print-width
Expand All @@ -77,7 +77,7 @@ repos:
- flake8-bugbear

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.2.0
hooks:
- id: ruff
args: ["--fix"]
1 change: 1 addition & 0 deletions src/lightning_utilities/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Core utilities."""

from lightning_utilities.core.apply_func import apply_to_collection
from lightning_utilities.core.enums import StrEnum
from lightning_utilities.core.imports import compare_version, module_available
Expand Down
6 changes: 2 additions & 4 deletions src/lightning_utilities/core/rank_zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@


@overload
def rank_zero_only(fn: Callable[P, T]) -> Callable[P, Optional[T]]:
...
def rank_zero_only(fn: Callable[P, T]) -> Callable[P, Optional[T]]: ...
Borda marked this conversation as resolved.
Show resolved Hide resolved


@overload
def rank_zero_only(fn: Callable[P, T], default: T) -> Callable[P, T]:
...
def rank_zero_only(fn: Callable[P, T], default: T) -> Callable[P, T]: ...


def rank_zero_only(fn: Callable[P, T], default: Optional[T] = None) -> Callable[P, Optional[T]]:
Expand Down
15 changes: 5 additions & 10 deletions tests/unittests/core/test_inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@


def test_get_all_subclasses():
class A1:
...
class A1: ...

class A2(A1):
...
class A2(A1): ...

class B1:
...
class B1: ...

class B2(B1):
...
class B2(B1): ...

class C(A2, B2):
...
class C(A2, B2): ...

assert get_all_subclasses(A1) == {A2, C}
assert get_all_subclasses(A2) == {C}
Expand Down
12 changes: 4 additions & 8 deletions tests/unittests/core/test_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@


class LightningModule:
def training_step(self):
...
def training_step(self): ...


class BoringModel(LightningModule):
def training_step(self):
...
def training_step(self): ...


class Strategy:
@contextmanager
def model_sharded_context():
...
def model_sharded_context(): ...


class SingleDeviceStrategy(Strategy):
...
class SingleDeviceStrategy(Strategy): ...


def test_is_overridden():
Expand Down
3 changes: 1 addition & 2 deletions tests/unittests/test/test_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ def test_no_warning_call():
with no_warning_call(DeprecationWarning):
warnings.warn("foo")

class MyDeprecationWarning(DeprecationWarning):
...
class MyDeprecationWarning(DeprecationWarning): ...

with pytest.raises(
AssertionError, match=escape("`DeprecationWarning` was raised: MyDeprecationWarning('bar')")
Expand Down
Loading