Skip to content

Commit 2cddbf0

Browse files
authored
Lint and fix undefined names (1/N) (comfyanonymous#6028)
1 parent 60749f3 commit 2cddbf0

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

comfy/gligen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import math
12
import torch
23
from torch import nn
34
from .ldm.modules.attention import CrossAttention

comfy/ldm/audio/dit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ def __init__(
228228
linear_in = GLU(dim, inner_dim, activation, dtype=dtype, device=device, operations=operations)
229229
else:
230230
linear_in = nn.Sequential(
231-
Rearrange('b n d -> b d n') if use_conv else nn.Identity(),
231+
rearrange('b n d -> b d n') if use_conv else nn.Identity(),
232232
operations.Linear(dim, inner_dim, bias = not no_bias, dtype=dtype, device=device) if not use_conv else operations.Conv1d(dim, inner_dim, conv_kernel_size, padding = (conv_kernel_size // 2), bias = not no_bias, dtype=dtype, device=device),
233-
Rearrange('b n d -> b d n') if use_conv else nn.Identity(),
233+
rearrange('b n d -> b d n') if use_conv else nn.Identity(),
234234
activation
235235
)
236236

@@ -245,9 +245,9 @@ def __init__(
245245

246246
self.ff = nn.Sequential(
247247
linear_in,
248-
Rearrange('b d n -> b n d') if use_conv else nn.Identity(),
248+
rearrange('b d n -> b n d') if use_conv else nn.Identity(),
249249
linear_out,
250-
Rearrange('b n d -> b d n') if use_conv else nn.Identity(),
250+
rearrange('b n d -> b d n') if use_conv else nn.Identity(),
251251
)
252252

253253
def forward(self, x):

comfy/ldm/models/autoencoder.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import logging
2+
import math
13
import torch
24
from contextlib import contextmanager
35
from typing import Any, Dict, Tuple, Union
@@ -52,7 +54,7 @@ def __init__(
5254

5355
if self.use_ema:
5456
self.model_ema = LitEma(self, decay=ema_decay)
55-
logpy.info(f"Keeping EMAs of {len(list(self.model_ema.buffers()))}.")
57+
logging.info(f"Keeping EMAs of {len(list(self.model_ema.buffers()))}.")
5658

5759
def get_input(self, batch) -> Any:
5860
raise NotImplementedError()
@@ -68,14 +70,14 @@ def ema_scope(self, context=None):
6870
self.model_ema.store(self.parameters())
6971
self.model_ema.copy_to(self)
7072
if context is not None:
71-
logpy.info(f"{context}: Switched to EMA weights")
73+
logging.info(f"{context}: Switched to EMA weights")
7274
try:
7375
yield None
7476
finally:
7577
if self.use_ema:
7678
self.model_ema.restore(self.parameters())
7779
if context is not None:
78-
logpy.info(f"{context}: Restored training weights")
80+
logging.info(f"{context}: Restored training weights")
7981

8082
def encode(self, *args, **kwargs) -> torch.Tensor:
8183
raise NotImplementedError("encode()-method of abstract base class called")
@@ -84,7 +86,7 @@ def decode(self, *args, **kwargs) -> torch.Tensor:
8486
raise NotImplementedError("decode()-method of abstract base class called")
8587

8688
def instantiate_optimizer_from_config(self, params, lr, cfg):
87-
logpy.info(f"loading >>> {cfg['target']} <<< optimizer from config")
89+
logging.info(f"loading >>> {cfg['target']} <<< optimizer from config")
8890
return get_obj_from_str(cfg["target"])(
8991
params, lr=lr, **cfg.get("params", dict())
9092
)
@@ -112,7 +114,7 @@ def __init__(
112114

113115
self.encoder: torch.nn.Module = instantiate_from_config(encoder_config)
114116
self.decoder: torch.nn.Module = instantiate_from_config(decoder_config)
115-
self.regularization: AbstractRegularizer = instantiate_from_config(
117+
self.regularization = instantiate_from_config(
116118
regularizer_config
117119
)
118120

comfy/ldm/modules/diffusionmodules/mmdit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from functools import partial
12
from typing import Dict, Optional, List
23

34
import numpy as np

ruff.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ lint.select = [
66
"S307", # suspicious-eval-usage
77
"F401", # unused-import
88
"F841", # unused-local-variable
9+
# TODO: Enable F821 after all errors has been fixed. Remaining errors: 7.
10+
# "F821", # undefined-name
911
]

0 commit comments

Comments
 (0)