mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-28 23:30:16 +08:00
Fix pylint issue with hydit, fix absolute versus relative imports
This commit is contained in:
parent
653a970088
commit
a6a080487f
@ -52,7 +52,7 @@ ignore=CVS
|
|||||||
# ignore-list. The regex matches against paths and can be in Posix or Windows
|
# ignore-list. The regex matches against paths and can be in Posix or Windows
|
||||||
# format. Because '\\' represents the directory delimiter on Windows systems,
|
# format. Because '\\' represents the directory delimiter on Windows systems,
|
||||||
# it can't be used as an escape character.
|
# it can't be used as an escape character.
|
||||||
ignore-paths=
|
ignore-paths=^comfy/api/.*$
|
||||||
|
|
||||||
# Files or directories matching the regular expression patterns are skipped.
|
# Files or directories matching the regular expression patterns are skipped.
|
||||||
# The regex matches against base names, not paths. The default value ignores
|
# The regex matches against base names, not paths. The default value ignores
|
||||||
@ -64,7 +64,7 @@ ignore-patterns=^\.#
|
|||||||
# manipulated during runtime and thus existing member attributes cannot be
|
# manipulated during runtime and thus existing member attributes cannot be
|
||||||
# deduced by static analysis). It supports qualified module names, as well as
|
# deduced by static analysis). It supports qualified module names, as well as
|
||||||
# Unix pattern matching.
|
# Unix pattern matching.
|
||||||
ignored-modules=sentencepiece.*
|
ignored-modules=sentencepiece.*,comfy.api
|
||||||
|
|
||||||
# Python code to execute, usually for sys.path manipulation such as
|
# Python code to execute, usually for sys.path manipulation such as
|
||||||
# pygtk.require().
|
# pygtk.require().
|
||||||
@ -82,7 +82,7 @@ limit-inference-results=100
|
|||||||
|
|
||||||
# List of plugins (as comma separated values of python module names) to load,
|
# List of plugins (as comma separated values of python module names) to load,
|
||||||
# usually to register additional checkers.
|
# usually to register additional checkers.
|
||||||
load-plugins=
|
load-plugins=tests.absolute_import_checker
|
||||||
|
|
||||||
# Pickle collected data for later comparisons.
|
# Pickle collected data for later comparisons.
|
||||||
persistent=yes
|
persistent=yes
|
||||||
@ -677,8 +677,7 @@ disable=raw-checker-failed,
|
|||||||
# either give multiple identifier separated by comma (,) or put this option
|
# either give multiple identifier separated by comma (,) or put this option
|
||||||
# multiple time (only on the command line, not in the configuration file where
|
# multiple time (only on the command line, not in the configuration file where
|
||||||
# it should appear only once). See also the "--disable" option for examples.
|
# it should appear only once). See also the "--disable" option for examples.
|
||||||
enable=
|
enable=absolute-import-used
|
||||||
|
|
||||||
|
|
||||||
[METHOD_ARGS]
|
[METHOD_ARGS]
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ class _RoutesWrapper:
|
|||||||
def _decorator_factory(self, method):
|
def _decorator_factory(self, method):
|
||||||
def decorator(path):
|
def decorator(path):
|
||||||
def wrapper(func):
|
def wrapper(func):
|
||||||
from comfy.cmd.server import PromptServer
|
from ..cmd.server import PromptServer
|
||||||
if PromptServer.instance is not None:
|
if PromptServer.instance is not None:
|
||||||
getattr(PromptServer.instance.routes, method)(path)(func)
|
getattr(PromptServer.instance.routes, method)(path)(func)
|
||||||
self.routes.append((method, path, func))
|
self.routes.append((method, path, func))
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class ModelManageable(Protocol):
|
|||||||
return self.model_size()
|
return self.model_size()
|
||||||
|
|
||||||
def memory_required(self, input_shape) -> int:
|
def memory_required(self, input_shape) -> int:
|
||||||
from comfy.model_base import BaseModel
|
from .model_base import BaseModel
|
||||||
|
|
||||||
if isinstance(self.model, BaseModel):
|
if isinstance(self.model, BaseModel):
|
||||||
return self.model.memory_required(input_shape=input_shape)
|
return self.model.memory_required(input_shape=input_shape)
|
||||||
|
|||||||
@ -103,7 +103,7 @@ def _import_and_enumerate_nodes_in_module(module: types.ModuleType,
|
|||||||
@tracer.start_as_current_span("Import All Nodes In Workspace")
|
@tracer.start_as_current_span("Import All Nodes In Workspace")
|
||||||
def import_all_nodes_in_workspace(vanilla_custom_nodes=True, raise_on_failure=False) -> ExportedNodes:
|
def import_all_nodes_in_workspace(vanilla_custom_nodes=True, raise_on_failure=False) -> ExportedNodes:
|
||||||
# now actually import the nodes, to improve control of node loading order
|
# now actually import the nodes, to improve control of node loading order
|
||||||
from comfy_extras import nodes as comfy_extras_nodes
|
from comfy_extras import nodes as comfy_extras_nodes # pylint: disable=absolute-import-used
|
||||||
from ..cli_args import args
|
from ..cli_args import args
|
||||||
from . import base_nodes
|
from . import base_nodes
|
||||||
from .vanilla_node_importing import mitigated_import_of_vanilla_custom_nodes
|
from .vanilla_node_importing import mitigated_import_of_vanilla_custom_nodes
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import copy
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from transformers import BertTokenizer
|
from transformers import BertTokenizer
|
||||||
|
|
||||||
|
|||||||
42
tests/absolute_import_checker.py
Normal file
42
tests/absolute_import_checker.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import os
|
||||||
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from astroid import nodes
|
||||||
|
from pylint.checkers import BaseChecker
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from pylint.lint import PyLinter
|
||||||
|
|
||||||
|
|
||||||
|
class AbsoluteImportChecker(BaseChecker):
|
||||||
|
"""Checker for detecting absolute imports within the same package."""
|
||||||
|
|
||||||
|
name = 'absolute-import'
|
||||||
|
msgs = {
|
||||||
|
'W0001': (
|
||||||
|
'Absolute import from same package used: %s',
|
||||||
|
'absolute-import-used',
|
||||||
|
'Use relative imports instead of absolute imports from the same package.'
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, linter: Optional["PyLinter"] = None) -> None:
|
||||||
|
super().__init__(linter)
|
||||||
|
|
||||||
|
def visit_importfrom(self, node: nodes.ImportFrom) -> None:
|
||||||
|
current_file = node.root().file
|
||||||
|
if current_file is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
package_path = os.path.dirname(current_file)
|
||||||
|
package_name = os.path.basename(package_path)
|
||||||
|
|
||||||
|
if node.modname.startswith(package_name) and package_name in ['comfy', 'comfy_extras']:
|
||||||
|
import_parts = node.modname.split('.')
|
||||||
|
|
||||||
|
if import_parts[0] == package_name:
|
||||||
|
self.add_message('absolute-import-used', node=node, args=(node.modname,))
|
||||||
|
|
||||||
|
|
||||||
|
def register(linter: "PyLinter") -> None:
|
||||||
|
linter.register_checker(AbsoluteImportChecker(linter))
|
||||||
Loading…
Reference in New Issue
Block a user