Skip to content

Commit

Permalink
Typecheck all init files
Browse files Browse the repository at this point in the history
  • Loading branch information
philippmwirth committed Sep 7, 2023
1 parent 9cb9202 commit 4c44677
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 206 deletions.
11 changes: 0 additions & 11 deletions lightly/active_learning/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions lightly/active_learning/config/__init__.py

This file was deleted.

54 changes: 0 additions & 54 deletions lightly/active_learning/config/selection_config.py

This file was deleted.

23 changes: 13 additions & 10 deletions lightly/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from lightly.api import patch as _patch
from lightly.api.api_workflow_artifacts import ArtifactNotExist
from lightly.api.api_workflow_client import ApiWorkflowClient
from lightly.openapi_generated.swagger_client.api_client import (
Configuration as _Configuration,
)
from typing import TYPE_CHECKING

# Make ApiWorkflowClient and swagger classes picklable.
_patch.make_swagger_configuration_picklable(
configuration_cls=_Configuration,
)
if not TYPE_CHECKING:
from lightly.api import patch as _patch
from lightly.api.api_workflow_artifacts import ArtifactNotExist
from lightly.api.api_workflow_client import ApiWorkflowClient
from lightly.openapi_generated.swagger_client.api_client import (
Configuration as _Configuration,
)

# Make ApiWorkflowClient and swagger classes picklable.
_patch.make_swagger_configuration_picklable(
configuration_cls=_Configuration,
)
12 changes: 7 additions & 5 deletions lightly/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from typing import TYPE_CHECKING

from lightly.cli.crop_cli import crop_cli
from lightly.cli.download_cli import download_cli
from lightly.cli.embed_cli import embed_cli
from lightly.cli.lightly_cli import lightly_cli
from lightly.cli.train_cli import train_cli
if not TYPE_CHECKING:
from lightly.cli.crop_cli import crop_cli
from lightly.cli.download_cli import download_cli
from lightly.cli.embed_cli import embed_cli
from lightly.cli.lightly_cli import lightly_cli
from lightly.cli.train_cli import train_cli
44 changes: 23 additions & 21 deletions lightly/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from typing import TYPE_CHECKING

from lightly.data._video import (
EmptyVideoError,
NonIncreasingTimestampError,
UnseekableTimestampError,
VideoError,
)
from lightly.data.collate import (
BaseCollateFunction,
DINOCollateFunction,
ImageCollateFunction,
MAECollateFunction,
MoCoCollateFunction,
MSNCollateFunction,
MultiCropCollateFunction,
PIRLCollateFunction,
SimCLRCollateFunction,
SwaVCollateFunction,
VICRegLCollateFunction,
imagenet_normalize,
)
from lightly.data.dataset import LightlyDataset
if not TYPE_CHECKING:
from lightly.data._video import (
EmptyVideoError,
NonIncreasingTimestampError,
UnseekableTimestampError,
VideoError,
)
from lightly.data.collate import (
BaseCollateFunction,
DINOCollateFunction,
ImageCollateFunction,
MAECollateFunction,
MoCoCollateFunction,
MSNCollateFunction,
MultiCropCollateFunction,
PIRLCollateFunction,
SimCLRCollateFunction,
SwaVCollateFunction,
VICRegLCollateFunction,
imagenet_normalize,
)
from lightly.data.dataset import LightlyDataset
7 changes: 5 additions & 2 deletions lightly/embedding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved

from lightly.embedding._base import BaseEmbedding
from lightly.embedding.embedding import SelfSupervisedEmbedding
from typing import TYPE_CHECKING

if not TYPE_CHECKING:
from lightly.embedding._base import BaseEmbedding
from lightly.embedding.embedding import SelfSupervisedEmbedding
26 changes: 14 additions & 12 deletions lightly/loss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from typing import TYPE_CHECKING

from lightly.loss.barlow_twins_loss import BarlowTwinsLoss
from lightly.loss.dcl_loss import DCLLoss, DCLWLoss
from lightly.loss.dino_loss import DINOLoss
from lightly.loss.msn_loss import MSNLoss
from lightly.loss.negative_cosine_similarity import NegativeCosineSimilarity
from lightly.loss.ntx_ent_loss import NTXentLoss
from lightly.loss.pmsn_loss import PMSNCustomLoss, PMSNLoss
from lightly.loss.swav_loss import SwaVLoss
from lightly.loss.sym_neg_cos_sim_loss import SymNegCosineSimilarityLoss
from lightly.loss.tico_loss import TiCoLoss
from lightly.loss.vicreg_loss import VICRegLoss
from lightly.loss.vicregl_loss import VICRegLLoss
if not TYPE_CHECKING:
from lightly.loss.barlow_twins_loss import BarlowTwinsLoss
from lightly.loss.dcl_loss import DCLLoss, DCLWLoss
from lightly.loss.dino_loss import DINOLoss
from lightly.loss.msn_loss import MSNLoss
from lightly.loss.negative_cosine_similarity import NegativeCosineSimilarity
from lightly.loss.ntx_ent_loss import NTXentLoss
from lightly.loss.pmsn_loss import PMSNCustomLoss, PMSNLoss
from lightly.loss.swav_loss import SwaVLoss
from lightly.loss.sym_neg_cos_sim_loss import SymNegCosineSimilarityLoss
from lightly.loss.tico_loss import TiCoLoss
from lightly.loss.vicreg_loss import VICRegLoss
from lightly.loss.vicregl_loss import VICRegLLoss
4 changes: 3 additions & 1 deletion lightly/loss/regularizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@

# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from typing import TYPE_CHECKING

from lightly.loss.regularizer.co2 import CO2Regularizer
if not TYPE_CHECKING:
from lightly.loss.regularizer.co2 import CO2Regularizer
20 changes: 11 additions & 9 deletions lightly/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from typing import TYPE_CHECKING

from lightly.models import utils
from lightly.models.barlowtwins import BarlowTwins
from lightly.models.byol import BYOL
from lightly.models.moco import MoCo
from lightly.models.nnclr import NNCLR
from lightly.models.resnet import ResNetGenerator
from lightly.models.simclr import SimCLR
from lightly.models.simsiam import SimSiam
from lightly.models.zoo import ZOO, checkpoints
if not TYPE_CHECKING:
from lightly.models import utils
from lightly.models.barlowtwins import BarlowTwins
from lightly.models.byol import BYOL
from lightly.models.moco import MoCo
from lightly.models.nnclr import NNCLR
from lightly.models.resnet import ResNetGenerator
from lightly.models.simclr import SimCLR
from lightly.models.simsiam import SimSiam
from lightly.models.zoo import ZOO, checkpoints
54 changes: 28 additions & 26 deletions lightly/models/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@

# Copyright (c) 2021. Lightly AG and its affiliates.
# All Rights Reserved
from typing import TYPE_CHECKING

from lightly import _torchvision_vit_available
from lightly.models.modules.heads import (
BarlowTwinsProjectionHead,
BYOLPredictionHead,
BYOLProjectionHead,
DINOProjectionHead,
MoCoProjectionHead,
NNCLRPredictionHead,
NNCLRProjectionHead,
SimCLRProjectionHead,
SimSiamPredictionHead,
SimSiamProjectionHead,
SMoGPredictionHead,
SMoGProjectionHead,
SMoGPrototypes,
SwaVProjectionHead,
SwaVPrototypes,
)
from lightly.models.modules.nn_memory_bank import NNMemoryBankModule

if _torchvision_vit_available:
# Requires torchvision >=0.12
from lightly.models.modules.masked_autoencoder import (
MAEBackbone,
MAEDecoder,
MAEEncoder,
if not TYPE_CHECKING:
from lightly import _torchvision_vit_available
from lightly.models.modules.heads import (
BarlowTwinsProjectionHead,
BYOLPredictionHead,
BYOLProjectionHead,
DINOProjectionHead,
MoCoProjectionHead,
NNCLRPredictionHead,
NNCLRProjectionHead,
SimCLRProjectionHead,
SimSiamPredictionHead,
SimSiamProjectionHead,
SMoGPredictionHead,
SMoGProjectionHead,
SMoGPrototypes,
SwaVProjectionHead,
SwaVPrototypes,
)
from lightly.models.modules.nn_memory_bank import NNMemoryBankModule

if _torchvision_vit_available:
# Requires torchvision >=0.12
from lightly.models.modules.masked_autoencoder import (
MAEBackbone,
MAEDecoder,
MAEEncoder,
)
58 changes: 33 additions & 25 deletions lightly/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,37 @@

# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from typing import TYPE_CHECKING

from lightly.transforms.byol_transform import (
BYOLTransform,
BYOLView1Transform,
BYOLView2Transform,
)
from lightly.transforms.dino_transform import DINOTransform, DINOViewTransform
from lightly.transforms.fast_siam_transform import FastSiamTransform
from lightly.transforms.gaussian_blur import GaussianBlur
from lightly.transforms.jigsaw import Jigsaw
from lightly.transforms.mae_transform import MAETransform
from lightly.transforms.moco_transform import MoCoV1Transform, MoCoV2Transform
from lightly.transforms.msn_transform import MSNTransform, MSNViewTransform
from lightly.transforms.pirl_transform import PIRLTransform
from lightly.transforms.rotation import (
RandomRotate,
RandomRotateDegrees,
random_rotation_transform,
)
from lightly.transforms.simclr_transform import SimCLRTransform, SimCLRViewTransform
from lightly.transforms.simsiam_transform import SimSiamTransform, SimSiamViewTransform
from lightly.transforms.smog_transform import SMoGTransform, SmoGViewTransform
from lightly.transforms.solarize import RandomSolarization
from lightly.transforms.swav_transform import SwaVTransform, SwaVViewTransform
from lightly.transforms.vicreg_transform import VICRegTransform, VICRegViewTransform
from lightly.transforms.vicregl_transform import VICRegLTransform, VICRegLViewTransform
if not TYPE_CHECKING:
from lightly.transforms.byol_transform import (
BYOLTransform,
BYOLView1Transform,
BYOLView2Transform,
)
from lightly.transforms.dino_transform import DINOTransform, DINOViewTransform
from lightly.transforms.fast_siam_transform import FastSiamTransform
from lightly.transforms.gaussian_blur import GaussianBlur
from lightly.transforms.jigsaw import Jigsaw
from lightly.transforms.mae_transform import MAETransform
from lightly.transforms.moco_transform import MoCoV1Transform, MoCoV2Transform
from lightly.transforms.msn_transform import MSNTransform, MSNViewTransform
from lightly.transforms.pirl_transform import PIRLTransform
from lightly.transforms.rotation import (
RandomRotate,
RandomRotateDegrees,
random_rotation_transform,
)
from lightly.transforms.simclr_transform import SimCLRTransform, SimCLRViewTransform
from lightly.transforms.simsiam_transform import (
SimSiamTransform,
SimSiamViewTransform,
)
from lightly.transforms.smog_transform import SMoGTransform, SmoGViewTransform
from lightly.transforms.solarize import RandomSolarization
from lightly.transforms.swav_transform import SwaVTransform, SwaVViewTransform
from lightly.transforms.vicreg_transform import VICRegTransform, VICRegViewTransform
from lightly.transforms.vicregl_transform import (
VICRegLTransform,
VICRegLViewTransform,
)
17 changes: 11 additions & 6 deletions lightly/utils/benchmarking/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from lightly.utils.benchmarking.benchmark_module import BenchmarkModule
from lightly.utils.benchmarking.knn import knn_predict
from lightly.utils.benchmarking.knn_classifier import KNNClassifier
from lightly.utils.benchmarking.linear_classifier import LinearClassifier
from lightly.utils.benchmarking.metric_callback import MetricCallback
from lightly.utils.benchmarking.online_linear_classifier import OnlineLinearClassifier
from typing import TYPE_CHECKING

if not TYPE_CHECKING:
from lightly.utils.benchmarking.benchmark_module import BenchmarkModule
from lightly.utils.benchmarking.knn import knn_predict
from lightly.utils.benchmarking.knn_classifier import KNNClassifier
from lightly.utils.benchmarking.linear_classifier import LinearClassifier
from lightly.utils.benchmarking.metric_callback import MetricCallback
from lightly.utils.benchmarking.online_linear_classifier import (
OnlineLinearClassifier,
)
Loading

0 comments on commit 4c44677

Please sign in to comment.