Repository: lightly-ai/lightly (branch: master)
Commit date: 2024-01-05T14:24:54Z

Workflow file: .github/workflows/test_code_format.yml (Code Format Check)
name: Code Format Check

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  test:
    name: Check
    runs-on: ubuntu-latest
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
    - name: Checkout Code
      uses: actions/checkout@v3
    - name: Hack to get setup-python to work on nektos/act
      run: |
        if [ ! -f "/etc/lsb-release" ] ; then
          echo "DISTRIB_RELEASE=18.04" > /etc/lsb-release
        fi
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.7"
    - uses: actions/cache@v2
      with:
        path: ${{ env.pythonLocation }}
        key: cache_v2_${{ env.pythonLocation }}-${{ hashFiles('requirements/**') }}
    - name: Install Dependencies and lightly
      run: pip install -e '.[all]'
    - name: Run Format Check
      run: |
        make format-check
    - name: Run Type Check
      run: |
        make type-check

env:
  PIP_INDEX_URL: http://localhost:8629/2024-01-05
  UV_INDEX_URL: http://localhost:8629/2024-01-05


Failed build logs:
step_name: Check/8_Run Type Check.txt
log: ##[group]Run make type-check
[36;1mmake type-check[0m
shell: /usr/bin/bash -e {0}
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.7.17/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.7.17/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.17/x64/lib
##[endgroup]
mypy lightly tests
lightly/loss/ssley_loss.py:6: note: In module imported here:
lightly/utils/dist.py: note: In class "GatherLayer":
lightly/utils/dist.py:19: error: Signature of "forward" incompatible with supertype "Function"  [override]
lightly/utils/dist.py:19: note: Error code "override" not covered by "type: ignore" comment
lightly/utils/dist.py:19: note:      Superclass:
lightly/utils/dist.py:19: note:          @staticmethod
lightly/utils/dist.py:19: note:          def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any
lightly/utils/dist.py:19: note:      Subclass:
lightly/utils/dist.py:19: note:          @staticmethod
lightly/utils/dist.py:19: note:          def forward(ctx: Any, input: Tensor) -> tuple[Tensor, ...]
Found 1 error in 1 file (checked 362 source files)
make: *** [Makefile:68: type-check] Error 1
##[error]Process completed with exit code 2.


Changed files:
lightly/utils/dist.py

Fix diff:
diff --git a/lightly/utils/dist.py b/lightly/utils/dist.py
index f44df6b9..88407556 100644
--- a/lightly/utils/dist.py
+++ b/lightly/utils/dist.py
@@ -14,9 +14,11 @@ class GatherLayer(Function):
 
     """
 
-    # Type ignore is required because superclass uses Any type for ctx.
+    # Type ignore misc is required because the superclass uses Any type for ctx.
+    # Type ignore override is required because the superclass has a different signature
+    # for forward.
     @staticmethod
-    def forward(ctx: Any, input: Tensor) -> Tuple[Tensor, ...]:  # type: ignore[misc]
+    def forward(ctx: Any, input: Tensor) -> Tuple[Tensor, ...]:  # type: ignore[misc, override]
         ctx.save_for_backward(input)
         output = [torch.empty_like(input) for _ in range(dist.get_world_size())]
         dist.all_gather(output, input)