Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit suggestions (#226)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit suggestions

updates:
- [github.com/psf/black: 23.11.0 → 24.1.1](psf/black@23.11.0...24.1.1)
- [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.8](pre-commit/mirrors-prettier@v3.1.0...v4.0.0-alpha.8)
- [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.2.0](astral-sh/ruff-pre-commit@v0.1.6...v0.2.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka Borovec <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and Borda authored Feb 15, 2024
1 parent 3c3eeaf commit acc8733
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 26 deletions.
4 changes: 2 additions & 2 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 Down Expand Up @@ -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]]: ...


@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

0 comments on commit acc8733

Please sign in to comment.