Skip to content

Commit 65cfcf5

Browse files
New Year ruff cleanup. (#11595)
1 parent 1bdc9a9 commit 65cfcf5

File tree

14 files changed

+35
-22
lines changed

14 files changed

+35
-22
lines changed

app/model_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def get_model_folders(request):
4444
@routes.get("/experiment/models/{folder}")
4545
async def get_all_models(request):
4646
folder = request.match_info.get("folder", None)
47-
if not folder in folder_paths.folder_names_and_paths:
47+
if folder not in folder_paths.folder_names_and_paths:
4848
return web.Response(status=404)
4949
files = self.get_model_file_list(folder)
5050
return web.json_response(files)
@@ -55,7 +55,7 @@ async def get_model_preview(request):
5555
path_index = int(request.match_info.get("path_index", None))
5656
filename = request.match_info.get("filename", None)
5757

58-
if not folder_name in folder_paths.folder_names_and_paths:
58+
if folder_name not in folder_paths.folder_names_and_paths:
5959
return web.Response(status=404)
6060

6161
folders = folder_paths.folder_names_and_paths[folder_name]

comfy/hooks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ def prepare_current_keyframe(self, curr_t: float, transformer_options: dict[str,
527527
if self._current_keyframe.get_effective_guarantee_steps(max_sigma) > 0:
528528
break
529529
# if eval_c is outside the percent range, stop looking further
530-
else: break
530+
else:
531+
break
531532
# update steps current context is used
532533
self._current_used_steps += 1
533534
# update current timestep this was performed on

comfy/ldm/chroma_radiance/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def radiance_get_override_params(self, overrides: dict) -> ChromaRadianceParams:
270270
bad_keys = tuple(
271271
k
272272
for k, v in overrides.items()
273-
if type(v) != type(getattr(params, k)) and (v is not None or k not in nullable_keys)
273+
if not isinstance(v, type(getattr(params, k))) and (v is not None or k not in nullable_keys)
274274
)
275275
if bad_keys:
276276
e = f"Invalid value(s) in transformer_options chroma_radiance_options: {', '.join(bad_keys)}"

comfy/ldm/hunyuan_video/upsampler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import torch.nn.functional as F
44
from comfy.ldm.modules.diffusionmodules.model import ResnetBlock, VideoConv3d
55
from comfy.ldm.hunyuan_video.vae_refiner import RMS_norm
6-
import model_management, model_patcher
6+
import model_management
7+
import model_patcher
78

89
class SRResidualCausalBlock3D(nn.Module):
910
def __init__(self, channels: int):

comfy/ldm/modules/diffusionmodules/model.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ def __init__(self, *, ch, out_ch, ch_mult=(1,2,4,8), num_res_blocks,
394394
attn_resolutions, dropout=0.0, resamp_with_conv=True, in_channels,
395395
resolution, use_timestep=True, use_linear_attn=False, attn_type="vanilla"):
396396
super().__init__()
397-
if use_linear_attn: attn_type = "linear"
397+
if use_linear_attn:
398+
attn_type = "linear"
398399
self.ch = ch
399400
self.temb_ch = self.ch*4
400401
self.num_resolutions = len(ch_mult)
@@ -548,7 +549,8 @@ def __init__(self, *, ch, out_ch, ch_mult=(1,2,4,8), num_res_blocks,
548549
conv3d=False, time_compress=None,
549550
**ignore_kwargs):
550551
super().__init__()
551-
if use_linear_attn: attn_type = "linear"
552+
if use_linear_attn:
553+
attn_type = "linear"
552554
self.ch = ch
553555
self.temb_ch = 0
554556
self.num_resolutions = len(ch_mult)

comfy/ldm/modules/ema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def forward(self, model):
4545
shadow_params[sname] = shadow_params[sname].type_as(m_param[key])
4646
shadow_params[sname].sub_(one_minus_decay * (shadow_params[sname] - m_param[key]))
4747
else:
48-
assert not key in self.m_name2s_name
48+
assert key not in self.m_name2s_name
4949

5050
def copy_to(self, model):
5151
m_param = dict(model.named_parameters())
@@ -54,7 +54,7 @@ def copy_to(self, model):
5454
if m_param[key].requires_grad:
5555
m_param[key].data.copy_(shadow_params[self.m_name2s_name[key]].data)
5656
else:
57-
assert not key in self.m_name2s_name
57+
assert key not in self.m_name2s_name
5858

5959
def store(self, parameters):
6060
"""

comfy/ldm/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def count_params(model, verbose=False):
7171

7272

7373
def instantiate_from_config(config):
74-
if not "target" in config:
74+
if "target" not in config:
7575
if config == '__is_first_stage__':
7676
return None
7777
elif config == "__is_unconditional__":

comfy/taesd/taehv.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ def show_progress_bar(self, value):
154154
self._show_progress_bar = value
155155

156156
def encode(self, x, **kwargs):
157-
if self.patch_size > 1: x = F.pixel_unshuffle(x, self.patch_size)
157+
if self.patch_size > 1:
158+
x = F.pixel_unshuffle(x, self.patch_size)
158159
x = x.movedim(2, 1) # [B, C, T, H, W] -> [B, T, C, H, W]
159160
if x.shape[1] % 4 != 0:
160161
# pad at end to multiple of 4
@@ -167,5 +168,6 @@ def encode(self, x, **kwargs):
167168
def decode(self, x, **kwargs):
168169
x = self.process_in(x).movedim(2, 1) # [B, C, T, H, W] -> [B, T, C, H, W]
169170
x = apply_model_with_memblocks(self.decoder, x, self.parallel, self.show_progress_bar)
170-
if self.patch_size > 1: x = F.pixel_shuffle(x, self.patch_size)
171+
if self.patch_size > 1:
172+
x = F.pixel_shuffle(x, self.patch_size)
171173
return x[:, self.frames_to_trim:].movedim(2, 1)

comfy_execution/graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ def is_cached(self, node_id):
207207
return self.output_cache.get(node_id) is not None
208208

209209
def cache_link(self, from_node_id, to_node_id):
210-
if not to_node_id in self.execution_cache:
210+
if to_node_id not in self.execution_cache:
211211
self.execution_cache[to_node_id] = {}
212212
self.execution_cache[to_node_id][from_node_id] = self.output_cache.get(from_node_id)
213-
if not from_node_id in self.execution_cache_listeners:
213+
if from_node_id not in self.execution_cache_listeners:
214214
self.execution_cache_listeners[from_node_id] = set()
215215
self.execution_cache_listeners[from_node_id].add(to_node_id)
216216

217217
def get_cache(self, from_node_id, to_node_id):
218-
if not to_node_id in self.execution_cache:
218+
if to_node_id not in self.execution_cache:
219219
return None
220220
value = self.execution_cache[to_node_id].get(from_node_id)
221221
if value is None:

comfy_extras/nodes_apg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def execute(cls, model, eta, norm_threshold, momentum) -> io.NodeOutput:
5555
def pre_cfg_function(args):
5656
nonlocal running_avg, prev_sigma
5757

58-
if len(args["conds_out"]) == 1: return args["conds_out"]
58+
if len(args["conds_out"]) == 1:
59+
return args["conds_out"]
5960

6061
cond = args["conds_out"][0]
6162
uncond = args["conds_out"][1]

0 commit comments

Comments
 (0)