Add ruff rule for empty line with trailing whitespace. · code/app-python-comfyui@b504bd6 · GitHub
Skip to content

Commit b504bd6

Browse files
Add ruff rule for empty line with trailing whitespace.
1 parent d170292 commit b504bd6

20 files changed

Lines changed: 106 additions & 106 deletions

File tree

‎api_server/services/terminal_service.py‎

Lines changed: 3 additions & 3 deletions

‎app/model_manager.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def get_model_previews(self, filepath: str) -> list[str | BytesIO]:
177177
safetensors_images = json.loads(safetensors_images)
178178
for image in safetensors_images:
179179
result.append(BytesIO(base64.b64decode(image)))
180-
180+
181181
return result
182182

183183
def __exit__(self, exc_type, exc_value, traceback):

‎comfy/hooks.py‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __init__(self, strength_model=1.0, strength_clip=1.0):
105105
@property
106106
def strength_model(self):
107107
return self._strength_model * self.strength
108-
108+
109109
@property
110110
def strength_clip(self):
111111
return self._strength_clip * self.strength
@@ -118,7 +118,7 @@ def add_hook_patches(self, model: 'ModelPatcher', model_options: dict, target: E
118118
strength = self._strength_model
119119
else:
120120
strength = self._strength_clip
121-
121+
122122
if self.need_weight_init:
123123
key_map = {}
124124
if target == EnumWeightTarget.Model:
@@ -151,7 +151,7 @@ class PatchHook(Hook):
151151
def __init__(self):
152152
super().__init__(hook_type=EnumHookType.Patch)
153153
self.patches: dict = None
154-
154+
155155
def clone(self, subtype: Callable=None):
156156
if subtype is None:
157157
subtype = type(self)
@@ -164,7 +164,7 @@ class ObjectPatchHook(Hook):
164164
def __init__(self):
165165
super().__init__(hook_type=EnumHookType.ObjectPatch)
166166
self.object_patches: dict = None
167-
167+
168168
def clone(self, subtype: Callable=None):
169169
if subtype is None:
170170
subtype = type(self)
@@ -179,7 +179,7 @@ def __init__(self, key: str=None, models: list['ModelPatcher']=None):
179179
self.key = key
180180
self.models = models
181181
self.append_when_same = True
182-
182+
183183
def clone(self, subtype: Callable=None):
184184
if subtype is None:
185185
subtype = type(self)
@@ -216,7 +216,7 @@ def clone(self, subtype: Callable=None):
216216
c: WrapperHook = super().clone(subtype)
217217
c.wrappers_dict = self.wrappers_dict
218218
return c
219-
219+
220220
def add_hook_patches(self, model: 'ModelPatcher', model_options: dict, target: EnumWeightTarget, registered: list[Hook]):
221221
if not self.should_register(model, model_options, target, registered):
222222
return False
@@ -230,15 +230,15 @@ def __init__(self, key: str=None, injections: list['PatcherInjection']=None):
230230
super().__init__(hook_type=EnumHookType.SetInjections)
231231
self.key = key
232232
self.injections = injections
233-
233+
234234
def clone(self, subtype: Callable=None):
235235
if subtype is None:
236236
subtype = type(self)
237237
c: SetInjectionsHook = super().clone(subtype)
238238
c.key = self.key
239239
c.injections = self.injections.copy() if self.injections else self.injections
240240
return c
241-
241+
242242
def add_hook_injections(self, model: 'ModelPatcher'):
243243
# TODO: add functionality
244244
pass
@@ -250,10 +250,10 @@ def __init__(self):
250250
def add(self, hook: Hook):
251251
if hook not in self.hooks:
252252
self.hooks.append(hook)
253-
253+
254254
def contains(self, hook: Hook):
255255
return hook in self.hooks
256-
256+
257257
def clone(self):
258258
c = HookGroup()
259259
for hook in self.hooks:
@@ -266,7 +266,7 @@ def clone_and_combine(self, other: 'HookGroup'):
266266
for hook in other.hooks:
267267
c.add(hook.clone())
268268
return c
269-
269+
270270
def set_keyframes_on_hooks(self, hook_kf: 'HookKeyframeGroup'):
271271
if hook_kf is None:
272272
hook_kf = HookKeyframeGroup()
@@ -365,7 +365,7 @@ def __init__(self, strength: float, start_percent=0.0, guarantee_steps=1):
365365
self.start_percent = float(start_percent)
366366
self.start_t = 999999999.9
367367
self.guarantee_steps = guarantee_steps
368-
368+
369369
def clone(self):
370370
c = HookKeyframe(strength=self.strength,
371371
start_percent=self.start_percent, guarantee_steps=self.guarantee_steps)
@@ -395,7 +395,7 @@ def reset(self):
395395
self._current_strength = None
396396
self.curr_t = -1.
397397
self._set_first_as_current()
398-
398+
399399
def add(self, keyframe: HookKeyframe):
400400
# add to end of list, then sort
401401
self.keyframes.append(keyframe)
@@ -407,20 +407,20 @@ def _set_first_as_current(self):
407407
self._current_keyframe = self.keyframes[0]
408408
else:
409409
self._current_keyframe = None
410-
410+
411411
def has_index(self, index: int):
412412
return index >= 0 and index < len(self.keyframes)
413413

414414
def is_empty(self):
415415
return len(self.keyframes) == 0
416-
416+
417417
def clone(self):
418418
c = HookKeyframeGroup()
419419
for keyframe in self.keyframes:
420420
c.keyframes.append(keyframe.clone())
421421
c._set_first_as_current()
422422
return c
423-
423+
424424
def initialize_timesteps(self, model: 'BaseModel'):
425425
for keyframe in self.keyframes:
426426
keyframe.start_t = model.model_sampling.percent_to_sigma(keyframe.start_percent)
@@ -565,7 +565,7 @@ def load_hook_lora_for_models(model: 'ModelPatcher', clip: 'CLIP', lora: dict[st
565565
else:
566566
k = ()
567567
new_modelpatcher = None
568-
568+
569569
if clip is not None:
570570
new_clip = clip.clone()
571571
k1 = new_clip.patcher.add_hook_patches(hook=hook, patches=loaded, strength_patch=strength_clip)

‎comfy/model_patcher.py‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def set_model_options_pre_cfg_function(model_options, pre_cfg_function, disable_
8383

8484
def create_model_options_clone(orig_model_options: dict):
8585
return comfy.patcher_extension.copy_nested_dicts(orig_model_options)
86-
86+
8787
def create_hook_patches_clone(orig_hook_patches):
8888
new_hook_patches = {}
8989
for hook_ref in orig_hook_patches:
@@ -141,7 +141,7 @@ def __init__(self, model: 'ModelPatcher', skip_and_inject_on_exit_only=False):
141141
self.was_injected = False
142142
self.prev_skip_injection = False
143143
self.skip_and_inject_on_exit_only = skip_and_inject_on_exit_only
144-
144+
145145
def __enter__(self):
146146
self.was_injected = False
147147
self.prev_skip_injection = self.model.skip_injection
@@ -164,7 +164,7 @@ def __init__(self, initial: int, minimum=0):
164164
self.value = initial
165165
self.minimum = minimum
166166
# TODO: add a safe limit besides 0
167-
167+
168168
def use(self, weight: torch.Tensor):
169169
weight_size = weight.nelement() * weight.element_size()
170170
if self.is_useable(weight_size):
@@ -711,7 +711,7 @@ def partially_unload(self, device_to, memory_to_free=0):
711711
else:
712712
comfy.utils.set_attr_param(self.model, key, bk.weight)
713713
self.backup.pop(key)
714-
714+
715715
weight_key = "{}.weight".format(n)
716716
bias_key = "{}.bias".format(n)
717717
if move_weight:
@@ -789,15 +789,15 @@ def add_callback(self, call_type: str, callback: Callable):
789789
def add_callback_with_key(self, call_type: str, key: str, callback: Callable):
790790
c = self.callbacks.setdefault(call_type, {}).setdefault(key, [])
791791
c.append(callback)
792-
792+
793793
def remove_callbacks_with_key(self, call_type: str, key: str):
794794
c = self.callbacks.get(call_type, {})
795795
if key in c:
796796
c.pop(key)
797797

798798
def get_callbacks(self, call_type: str, key: str):
799799
return self.callbacks.get(call_type, {}).get(key, [])
800-
800+
801801
def get_all_callbacks(self, call_type: str):
802802
c_list = []
803803
for c in self.callbacks.get(call_type, {}).values():
@@ -810,7 +810,7 @@ def add_wrapper(self, wrapper_type: str, wrapper: Callable):
810810
def add_wrapper_with_key(self, wrapper_type: str, key: str, wrapper: Callable):
811811
w = self.wrappers.setdefault(wrapper_type, {}).setdefault(key, [])
812812
w.append(wrapper)
813-
813+
814814
def remove_wrappers_with_key(self, wrapper_type: str, key: str):
815815
w = self.wrappers.get(wrapper_type, {})
816816
if key in w:
@@ -831,7 +831,7 @@ def set_attachments(self, key: str, attachment):
831831
def remove_attachments(self, key: str):
832832
if key in self.attachments:
833833
self.attachments.pop(key)
834-
834+
835835
def get_attachment(self, key: str):
836836
return self.attachments.get(key, None)
837837

@@ -851,7 +851,7 @@ def remove_additional_models(self, key: str):
851851

852852
def get_additional_models_with_key(self, key: str):
853853
return self.additional_models.get(key, [])
854-
854+
855855
def get_additional_models(self):
856856
all_models = []
857857
for models in self.additional_models.values():
@@ -906,7 +906,7 @@ def pre_run(self):
906906
self.model.current_patcher = self
907907
for callback in self.get_all_callbacks(CallbacksMP.ON_PRE_RUN):
908908
callback(self)
909-
909+
910910
def prepare_state(self, timestep):
911911
for callback in self.get_all_callbacks(CallbacksMP.ON_PREPARE_STATE):
912912
callback(self, timestep)
@@ -918,7 +918,7 @@ def restore_hook_patches(self):
918918

919919
def set_hook_mode(self, hook_mode: comfy.hooks.EnumHookMode):
920920
self.hook_mode = hook_mode
921-
921+
922922
def prepare_hook_patches_current_keyframe(self, t: torch.Tensor, hook_group: comfy.hooks.HookGroup):
923923
curr_t = t[0]
924924
reset_current_hooks = False
@@ -975,7 +975,7 @@ def add_hook_patches(self, hook: comfy.hooks.WeightHook, patches, strength_patch
975975
key = k[0]
976976
if len(k) > 2:
977977
function = k[2]
978-
978+
979979
if key in model_sd:
980980
p.add(k)
981981
current_patches: list[tuple] = current_hook_patches.get(key, [])
@@ -1063,7 +1063,7 @@ def clear_cached_hook_weights(self):
10631063
def patch_hook_weight_to_device(self, hooks: comfy.hooks.HookGroup, combined_patches: dict, key: str, original_weights: dict, memory_counter: MemoryCounter):
10641064
if key not in combined_patches:
10651065
return
1066-
1066+
10671067
weight, set_func, convert_func = get_key_weight(self.model, key)
10681068
weight: torch.Tensor
10691069
if key not in self.hook_backup:
@@ -1098,7 +1098,7 @@ def patch_hook_weight_to_device(self, hooks: comfy.hooks.HookGroup, combined_pat
10981098
del temp_weight
10991099
del out_weight
11001100
del weight
1101-
1101+
11021102
def unpatch_hooks(self) -> None:
11031103
with self.use_ejected():
11041104
if len(self.hook_backup) == 0:
@@ -1107,7 +1107,7 @@ def unpatch_hooks(self) -> None:
11071107
keys = list(self.hook_backup.keys())
11081108
for k in keys:
11091109
comfy.utils.copy_to_param(self.model, k, self.hook_backup[k][0].to(device=self.hook_backup[k][1]))
1110-
1110+
11111111
self.hook_backup.clear()
11121112
self.current_hooks = None
11131113

‎comfy/patcher_extension.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ def __init__(self, original: Callable, class_obj: object, wrappers: list[Callabl
9696
self.wrappers = wrappers.copy()
9797
self.idx = idx
9898
self.is_last = idx == len(wrappers)
99-
99+
100100
def __call__(self, *args, **kwargs):
101101
"""Calls the next wrapper or original function, whichever is appropriate."""
102102
new_executor = self._create_next_executor()
103103
return new_executor.execute(*args, **kwargs)
104-
104+
105105
def execute(self, *args, **kwargs):
106106
"""Used to initiate executor internally - DO NOT use this if you received executor in wrapper."""
107107
args = list(args)
@@ -121,7 +121,7 @@ def _create_next_executor(self) -> 'WrapperExecutor':
121121
@classmethod
122122
def new_executor(cls, original: Callable, wrappers: list[Callable], idx=0):
123123
return cls(original, class_obj=None, wrappers=wrappers, idx=idx)
124-
124+
125125
@classmethod
126126
def new_class_executor(cls, original: Callable, class_obj: object, wrappers: list[Callable], idx=0):
127127
return cls(original, class_obj, wrappers, idx=idx)

‎comfy_execution/graph.py‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)