diff --git a/clinguin/__init__.py b/clinguin/__init__.py index df21fa31..87ddbd3c 100644 --- a/clinguin/__init__.py +++ b/clinguin/__init__.py @@ -1,6 +1,7 @@ """ Clinguin package - package entry point """ + import copy import sys import threading diff --git a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/__init__.py b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/__init__.py index 3f03df3a..e7e8237f 100644 --- a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/__init__.py +++ b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/__init__.py @@ -1,6 +1,7 @@ """ This package contains all tkinter_elements that are provided in clinguin. """ + from .button import Button from .canvas import Canvas from .container import Container diff --git a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/canvas.py b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/canvas.py index 71c98926..6f387ff4 100644 --- a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/canvas.py +++ b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/canvas.py @@ -1,6 +1,7 @@ """ Contains the canvas class. """ + import base64 import io import tkinter as tk diff --git a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/menu_bar.py b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/menu_bar.py index 137df60b..b24fae6d 100644 --- a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/menu_bar.py +++ b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/menu_bar.py @@ -1,6 +1,7 @@ """ This module features the MenuBar class. """ + import tkinter as tk from .root_cmp import RootCmp diff --git a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/menu_bar_section.py b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/menu_bar_section.py index 8d82f550..7893406e 100644 --- a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/menu_bar_section.py +++ b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/menu_bar_section.py @@ -1,6 +1,7 @@ """ Module contains the menu bar section class. """ + import tkinter as tk from clinguin.utils.attribute_types import StringType diff --git a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/message.py b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/message.py index bdb24223..05d5e28e 100644 --- a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/message.py +++ b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_elements/message.py @@ -1,6 +1,7 @@ """ Contains the Message class. """ + import tkinter as tk from tkinter import messagebox diff --git a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_utils/__init__.py b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_utils/__init__.py index 6621e221..0871bc68 100644 --- a/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_utils/__init__.py +++ b/clinguin/client/presentation/frontends/tkinter_frontend/tkinter_utils/__init__.py @@ -1,6 +1,7 @@ """ This module contains various utils for tkinter-elements, which reduce code size, etc. """ + from .attribute_names import AttributeNames from .call_back_definition import CallBackDefinition from .callback_names import CallbackNames diff --git a/clinguin/client_helper.py b/clinguin/client_helper.py index c46f0be2..ceb9556b 100644 --- a/clinguin/client_helper.py +++ b/clinguin/client_helper.py @@ -1,6 +1,7 @@ """ Helper for the client-startup-process """ + from clinguin.client import ClientBase from clinguin.utils import Logger diff --git a/clinguin/server/__init__.py b/clinguin/server/__init__.py index d32fdc02..14893b24 100644 --- a/clinguin/server/__init__.py +++ b/clinguin/server/__init__.py @@ -1,6 +1,7 @@ """ Server module, contains core-program classes. """ + from .application.standard_json_encoder import StandardJsonEncoder from .data.ui_state import UIState from .presentation.endpoints import Endpoints diff --git a/clinguin/server/application/attribute.py b/clinguin/server/application/attribute.py index 87a1e5b4..93d07cb3 100644 --- a/clinguin/server/application/attribute.py +++ b/clinguin/server/application/attribute.py @@ -1,6 +1,7 @@ """ Module contains the AttributeDto class. """ + import json diff --git a/clinguin/server/application/backends/clingo_backend.py b/clinguin/server/application/backends/clingo_backend.py index 1323b2de..6b0ba8b9 100644 --- a/clinguin/server/application/backends/clingo_backend.py +++ b/clinguin/server/application/backends/clingo_backend.py @@ -2,12 +2,12 @@ """ Module that contains the ClingoMultishotBackend. """ +import functools import logging -import time import textwrap +import time from functools import cached_property from pathlib import Path -import functools from typing import Any from clingo import Control, parse_term @@ -118,7 +118,8 @@ def register_options(cls, parser): help=textwrap.dedent( """\ Optional timeout for searching for optimal models. - The timeout is not exactly enforced (might take longer) but only checked after each solution is found. + The timeout is not exactly enforced (might take longer) + but only checked after each solution is found. """ ), type=int, @@ -172,7 +173,8 @@ def _restart(self): It is automatically called when the server starts. See Also: - :func:`~_init_command_line`, :func:`~_init_interactive`, :func:`~_outdate`, :func:`~_init_ctl`, :func:`~_ground` + :func:`~_init_command_line`, :func:`~_init_interactive`, + :func:`~_outdate`, :func:`~_init_ctl`, :func:`~_ground` """ self._init_command_line() self._init_interactive() @@ -232,7 +234,8 @@ def _init_command_line(self): _constants (dict): The dictionary of constants provided via command line. _clingo_ctl_arg (list): The list of clingo control arguments provided via command line. - If any command line arguments are added in :meth:`~ClingoBackend.register_options`, they should be initialized here. + If any command line arguments are added in :meth:`~ClingoBackend.register_options`, + they should be initialized here. Example: @@ -275,16 +278,19 @@ def _init_interactive(self): _handler (clingo.SolveHandle): The handler set while browsing in the `next_solution` operation. _iterator (iter): The iterator set while browsing in the `next_solution` operation. _ctl (clingo.Control): The domain control set in `_init_ctl`. - _ui_state (:class:`UIState`): A UIState object used to handle the UI construction, set in every call to `_update_ui_state`. + _ui_state (:class:`UIState`): A UIState object used to handle the UI construction, + set in every call to `_update_ui_state`. _atoms (set[str]): A set to store the atoms set dynamically in operations during the interaction. - _assumptions (set[str]): A set to store the assumptions set dynamically in operations during the interaction. + _assumptions (set[str]): A set to store the assumptions set dynamically in operations during the + interaction. _externals (dict): A dictionary with true, false and released sets of external atoms _model (list[clingo.Symbol]): The model set in `on_model`. _unsat_core (list[int]): The unsatisfiable core set in `on_model`. _cost (list): A list to store the cost set in `on_model`. _optimal (bool): A boolean indicating if the solution is optimal, set in `on_model`. _optimizing (bool): A boolean indicating if the solver is currently optimizing, set in `on_model`. - _messages (list[tuple[str,str,str]]): A list to store the messages (title, content, type) to be shown in the UI, set dynamically in operations during the interaction. + _messages (list[tuple[str,str,str]]): A list to store the messages (title, content, type) to be shown in + the UI, set dynamically in operations during the interaction. """ # Context: Set by the general handler of requests self._context = [] @@ -431,7 +437,7 @@ def _set_constant(self, name: str, value: Any) -> None: name = name.strip('"') value = str(value).strip('"') self._constants[name] = value - self._logger.debug(f"Constant {name} updated successfully to {value}") + self._logger.debug("Constant %s updated successfully to %s", name, value) def _add_atom(self, predicate_symbol): """ @@ -461,7 +467,6 @@ def _prepare(self): """ Does any preparation before a solve call. """ - pass def _on_model(self, model): """ @@ -529,7 +534,7 @@ def _call_solver_with_cache( The program tagged """ if self._is_browsing: - self._logger.debug(f"Returning cache for {ds_id}") + self._logger.debug("Returning cache for %s", ds_id) return ( self._backup_ds_cache[ds_id] if ds_id in self._backup_ds_cache else "" ) @@ -562,7 +567,7 @@ def _call_solver_with_cache( ) return " ".join([str(s) + "." for s in list(tag(symbols, ds_tag))]) + "\n" - @functools.lru_cache(maxsize=None) + @functools.lru_cache(maxsize=None) # pylint: disable=[method-cache-max-size-none] def _ui_uses_predicate(self, name: str, arity: int): """ Returns a truth value of weather the ui_files contain the given signature. @@ -572,7 +577,7 @@ def _ui_uses_predicate(self, name: str, arity: int): arity (int): Predicate arity """ transformer = UsesSignatureTransformer(name, arity) - self._logger.debug(f"Transformer parsing UI files to find {name}/{arity}") + self._logger.debug("Transformer parsing UI files to find %s/%s", name, arity) transformer.parse_files(self._ui_files) if not transformer.contained: self._logger.debug( @@ -768,7 +773,8 @@ def _ds_constants(self): """ Adds constants values. - Includes predicate ``_clinguin_const/2`` for each constant provided in the command line and used in the domain files. + Includes predicate ``_clinguin_const/2`` for each constant provided + in the command line and used in the domain files. """ prg = "#defined _clinguin_const/2. " for k, v in self._constants.items(): @@ -926,7 +932,8 @@ def next_solution(self, opt_mode="ignore"): ) ) self._logger.warning( - "No optimization statement provided in encoding but optimization condition provided in 'next_solution' operation. Exiting browsing." + "No optimization statement provided in encoding but optimization condition provided\ + in 'next_solution' operation. Exiting browsing." ) break if ( diff --git a/clinguin/server/application/backends/clingo_multishot_backend.py b/clinguin/server/application/backends/clingo_multishot_backend.py index b92f9db8..02129759 100644 --- a/clinguin/server/application/backends/clingo_multishot_backend.py +++ b/clinguin/server/application/backends/clingo_multishot_backend.py @@ -3,11 +3,11 @@ Module that contains the ClingoMultishotBackend. """ -from clingo import parse_term, Control +from clingo import Control, parse_term from clingo.script import enable_python -from clinguin.utils.annotations import overwrites, extends from clinguin.server.application.backends import ClingoBackend +from clinguin.utils.annotations import extends, overwrites from ....utils.logger import domctl_log diff --git a/clinguin/server/application/backends/clingodl_backend.py b/clinguin/server/application/backends/clingodl_backend.py index bd66e036..50ddc6c9 100644 --- a/clinguin/server/application/backends/clingodl_backend.py +++ b/clinguin/server/application/backends/clingodl_backend.py @@ -2,10 +2,8 @@ Module that contains the ClingoDL Backend. """ -from pathlib import Path import textwrap -from clingo import Control from clingo.ast import ProgramBuilder, parse_files from clingo.script import enable_python from clingodl import ClingoDLTheory diff --git a/clinguin/server/application/backends/clingraph_backend.py b/clinguin/server/application/backends/clingraph_backend.py index efd91f36..517cb1ab 100644 --- a/clinguin/server/application/backends/clingraph_backend.py +++ b/clinguin/server/application/backends/clingraph_backend.py @@ -2,9 +2,9 @@ """ Module that contains the ClingraphBackend. """ +import functools import textwrap from pathlib import Path -import functools from clingo import Control from clingo.symbol import Function, String @@ -19,9 +19,10 @@ # Self defined from clinguin.utils import StandardTextProcessing, image_to_b64 -from ....utils.transformer import UsesSignatureTransformer from clinguin.utils.annotations import extends, overwrites +from ....utils.transformer import UsesSignatureTransformer + class ClingraphBackend(ClingoMultishotBackend): """ @@ -36,6 +37,7 @@ def _init_command_line(self): Sets the arguments for computing clingraph images. """ super()._init_command_line() + # pylint: disable= attribute-defined-outside-init self._clingraph_files = self._args.clingraph_files self._select_model = self._args.select_model self._type = self._args.type @@ -199,7 +201,7 @@ def register_options(cls, parser): help="Intermediate format. Use 'svg' for angular fronted and 'png' tkinter. (default: %(default)s)", ) - @functools.lru_cache(maxsize=None) + @functools.lru_cache(maxsize=None) # pylint: disable=[method-cache-max-size-none] @overwrites(ClingoMultishotBackend) def _ui_uses_predicate(self, name: str, arity: int): """ @@ -210,7 +212,7 @@ def _ui_uses_predicate(self, name: str, arity: int): arity (int): Predicate arity """ transformer = UsesSignatureTransformer(name, arity) - self._logger.debug(f"Transformer parsing UI files to find {name}/{arity}") + self._logger.debug("Transformer parsing UI files to find %s/%s", name, arity) transformer.parse_files(self._ui_files + self._clingraph_files) return transformer.contained diff --git a/clinguin/server/application/backends/explanation_backend.py b/clinguin/server/application/backends/explanation_backend.py index 8b1efe23..c6fcecf5 100644 --- a/clinguin/server/application/backends/explanation_backend.py +++ b/clinguin/server/application/backends/explanation_backend.py @@ -5,17 +5,17 @@ import textwrap from functools import cached_property -from clingo.script import enable_python -from clingexplaid.transformers import AssumptionTransformer from clingexplaid.mus import CoreComputer - -from ....utils.logger import domctl_log +from clingexplaid.transformers import AssumptionTransformer +from clingo.script import enable_python from clinguin.server.application.backends.clingo_multishot_backend import ( ClingoMultishotBackend, ) from clinguin.utils.annotations import extends +from ....utils.logger import domctl_log + enable_python() @@ -33,7 +33,8 @@ class ExplanationBackend(ClingoMultishotBackend): @property def _assumption_list(self): """ - Gets the set of assumptions used for solving. It includes the assumptions from the assumption signatures provided. + Gets the set of assumptions used for solving. + It includes the assumptions from the assumption signatures provided. Warning: @@ -56,6 +57,7 @@ def _init_interactive(self): _mus (str): The list of assumptions in the MUS property """ super()._init_interactive() + # pylint: disable= attribute-defined-outside-init self._mus = None @extends(ClingoMultishotBackend) @@ -68,6 +70,7 @@ def _init_command_line(self): _assumption_transformer (clingexplaid.AssumptionTransformer): The transformer used for the input files """ super()._init_command_line() + # pylint: disable= attribute-defined-outside-init self._assumption_sig = [] for a in self._args.assumption_signature or []: try: @@ -103,14 +106,15 @@ def _load_file(self, f): # Solving # --------------------------------------------- @extends(ClingoMultishotBackend) - def _ground(self): + def _ground(self, program="base"): """ Sets the list of assumptions that were taken from the input files using the assumption_signature. Attributes: _assumptions_from_signature (Set[clingo.Symbol]): The set of assumptions from the assumption signatures """ - super()._ground() + super()._ground(program) + # pylint: disable= attribute-defined-outside-init self._assumptions_from_signature = ( self._assumption_transformer.get_assumption_symbols( self._ctl, arguments=self._ctl_arguments_list @@ -167,6 +171,6 @@ def _ds_mus(self): cc = CoreComputer(self._ctl, self._assumption_list) cc.shrink() mus_core = cc.minimal - for s, v in mus_core: + for s, _ in mus_core: prg = prg + f"_clinguin_mus({str(s)}).\n" return prg diff --git a/clinguin/server/application/backends/standard_utils/clingo_logger.py b/clinguin/server/application/backends/standard_utils/clingo_logger.py index fa4b3fcb..a94318b8 100644 --- a/clinguin/server/application/backends/standard_utils/clingo_logger.py +++ b/clinguin/server/application/backends/standard_utils/clingo_logger.py @@ -2,6 +2,7 @@ Clingo logger. TODO """ + from clingo import MessageCode diff --git a/clinguin/server/application/element.py b/clinguin/server/application/element.py index 3a889f85..915c58d4 100644 --- a/clinguin/server/application/element.py +++ b/clinguin/server/application/element.py @@ -1,6 +1,7 @@ """ Module that contains the ElementDto class. """ + import json diff --git a/clinguin/server/data/attribute.py b/clinguin/server/data/attribute.py index c39adb13..04999105 100644 --- a/clinguin/server/data/attribute.py +++ b/clinguin/server/data/attribute.py @@ -14,6 +14,8 @@ class AttributeDao(Predicate): - value: The value of the attribute. """ + # pylint: disable=abstract-method + id = RawField key = RawField value = RawField diff --git a/clinguin/server/data/callback.py b/clinguin/server/data/callback.py index 028ef48f..9b046930 100644 --- a/clinguin/server/data/callback.py +++ b/clinguin/server/data/callback.py @@ -10,15 +10,19 @@ class WhenDao(Predicate): Actions define the interactivity of the UI. Multiple actions are allowed, as explained below. - id: Identifier of the element that the user interacted with. - - event: The event that is being triggered, such as click, hover, input, etc. Each element type allows different events. + - event: The event that is being triggered, such as click, hover, input, etc. + Each element type allows different events. - action: The action performed. - call: Calls the server to perform an operation. - update: Updates the attribute of another element without any calls to the server. - - context: Updates the internal context that will be passed to the server on the following call actions. See Context for more details. + - context: Updates the internal context that will be passed to the server on the following call actions. + See Context for more details. - operation: The operation accounts for the information that the action requires for its execution. """ + # pylint: disable=abstract-method + id = RawField event = RawField action = RawField diff --git a/clinguin/server/data/element.py b/clinguin/server/data/element.py index d96c5f28..7533fe58 100644 --- a/clinguin/server/data/element.py +++ b/clinguin/server/data/element.py @@ -15,6 +15,8 @@ class ElementDao(Predicate): """ + # pylint: disable=abstract-method + id = RawField type = RawField parent = RawField diff --git a/clinguin/server/data/ui_state.py b/clinguin/server/data/ui_state.py index 202b168b..2a173602 100644 --- a/clinguin/server/data/ui_state.py +++ b/clinguin/server/data/ui_state.py @@ -7,20 +7,17 @@ from pathlib import Path import clorm -from clingo import Control - - +from clingo import Control, parse_term from clingo.symbol import Function, Number, String -from clingo import parse_term from clingraph.clingo_utils import ClingraphContext from clorm import Raw from clinguin.utils import StandardTextProcessing, image_to_b64 +from ...utils.logger import uictl_log from .attribute import AttributeDao from .callback import WhenDao from .element import ElementDao -from ...utils.logger import uictl_log log = logging.getLogger("clinguin_server") diff --git a/clinguin/server/presentation/endpoints.py b/clinguin/server/presentation/endpoints.py index 31102d70..feae484e 100644 --- a/clinguin/server/presentation/endpoints.py +++ b/clinguin/server/presentation/endpoints.py @@ -66,7 +66,7 @@ async def standard_executor(self): The get() method is implemented by every backend. """ self._logger.info(colored_text("=>=>=>=>=>=>=>=>=> GET", "GREEN")) - self._logger.info(colored_text("-->", "GREEN") + " get()") + self._logger.info("%s get()", colored_text("-->", "GREEN")) try: json = self._backend.get() self.last_response = json @@ -120,16 +120,14 @@ async def operation_executor(self, backend_call_string: BackendOperationDto): call_args = ",".join(function_arguments) self._logger.info( - colored_text("-->", "GREEN") + " %s(%s)", - function_name, - call_args, + "%s %s(%s)", colored_text("-->", "GREEN"), function_name, call_args ) EndpointsHelper.call_function( self._backend, function_name, function_arguments, {} ) - self._logger.info(colored_text("-->", "GREEN") + " get()") + self._logger.info(" get(%s)", colored_text("-->", "GREEN")) self.last_response = self._backend.get() self._logger.info(colored_text("--------------------", "GREEN")) diff --git a/clinguin/server_helper.py b/clinguin/server_helper.py index 243e1d40..ee56adc7 100644 --- a/clinguin/server_helper.py +++ b/clinguin/server_helper.py @@ -1,6 +1,7 @@ """ Responsible for starting the server """ + import uvicorn from fastapi import FastAPI from starlette.middleware.cors import CORSMiddleware diff --git a/clinguin/show_frontend_syntax_enum.py b/clinguin/show_frontend_syntax_enum.py index 70949b9d..89bbb9b9 100644 --- a/clinguin/show_frontend_syntax_enum.py +++ b/clinguin/show_frontend_syntax_enum.py @@ -1,6 +1,7 @@ """ Defines the possibilities how to show the syntax. """ + from enum import Enum, auto diff --git a/clinguin/utils/__init__.py b/clinguin/utils/__init__.py index bbc95fb6..81b06a64 100644 --- a/clinguin/utils/__init__.py +++ b/clinguin/utils/__init__.py @@ -1,6 +1,7 @@ """ The utils module of clinguin - contains some useful tools for clinguin. """ + from .attribute_types.utils.standard_text_processing import StandardTextProcessing from .case_converter import CaseConverter, image_to_b64 from .custom_args import CustomArgs diff --git a/clinguin/utils/annotations.py b/clinguin/utils/annotations.py index ba4053b8..c65661f2 100644 --- a/clinguin/utils/annotations.py +++ b/clinguin/utils/annotations.py @@ -1,10 +1,16 @@ -# import clinguin.server.application.backends -# from clinguin.server.application.backends import * - -import sys +""" +Annotations used to express overwrites and extensions of methods. +They enhance documentation and help to understand the code. +""" def extends(super_cls): + """ + Decorator to indicate that a method extends a method of a super class. + Args: + super_cls (_type_): The super class. + """ + def decorator(func): def wrapper(self, *args, **kwargs): return func(self, *args, **kwargs) @@ -23,6 +29,12 @@ def wrapper(self, *args, **kwargs): def overwrites(super_cls): + """ + Decorates a method to indicate that it overwrites a method of a super class. + Args: + super_cls (_type_): The super class. + """ + def decorator(func): def wrapper(self, *args, **kwargs): return func(self, *args, **kwargs) @@ -38,108 +50,3 @@ def wrapper(self, *args, **kwargs): return wrapper return decorator - - -# def overwrites(func): - -# def wrapper(self, *args, **kwargs): -# return func(self, *args, **kwargs) - -# cls_name = func.__qualname__.split(".")[0] -# module_name = func.__module__ -# module = sys.modules[module_name] -# cls = getattr(module, cls_name, None) - -# if cls is None: -# raise KeyError(f"Class {cls_name} not found in module {module_name}") - -# super_cls = cls.__bases__[0].__name__ -# overwrite_str = f""" -# Warning: -# Overwrites :meth:`{super_cls}.{func.__name__}` -# """ -# wrapper.__name__ = func.__name__ -# wrapper.__doc__ = (func.__doc__ or "") + overwrite_str - -# return wrapper - - -# import inspect - - -# def overwrites(func): -# def wrapper(self, *args, **kwargs): -# return func(self, *args, **kwargs) - -# cls = None -# for cls_candidate in inspect.getmro(type(func.__globals__)): -# if func.__name__ in cls_candidate.__dict__: -# cls = cls_candidate -# break - -# if cls is None: -# raise KeyError(f"Class for method {func.__name__} not found") - -# super_cls = cls.__bases__[0].__name__ -# overwrite_str = f""" -# Warning: -# Overwrites :meth:`{super_cls}.{func.__name__}` -# """ -# wrapper.__name__ = func.__name__ -# wrapper.__doc__ = (func.__doc__ or "") + overwrite_str - -# return wrapper - - -# # def overwrites(func): -# # def wrapper(self, *args, **kwargs): -# # return func(self, *args, **kwargs) - -# # cls = func.__qualname__.split(".")[0] -# # super_cls = func.__globals__[cls].__bases__[0].__name__ -# # overwrite_str = f""" -# # Warning: -# # Overwrites :meth:`{super_cls}.{func.__name__}` -# # """ -# # wrapper.__name__ = func.__name__ -# # wrapper.__doc__ = (func.__doc__ or "") + overwrite_str - -# # return wrapper - - -# # # def overwrites(func): -# # # cls = None -# # # cls = None - -# # # def wrapper(self, *args, **kwargs): -# # # cls = type(self) -# # # return func(self, *args, **kwargs) - -# # # overwrite_str = f""" -# # # Warning: -# # # {cls} -# # # {cls.__bases__} -# # # Overwrites :meth:`{func.__class__.__bases__[-1].__name__}.{func.__name__}` -# # # """ -# # # wrapper.__name__ = func.__name__ -# # # wrapper.__doc__ = func.__doc__ + overwrite_str - -# # # return wrapper - -# # # # def overwrites(func): - -# # # # def inner(): -# # # # func() - -# # # # help(func) -# # # overwrite_str = f""" -# # # Warning: -# # # {func.__class__} -# # # {func.__class__.__bases__} -# # # Overwrites :meth:`{func.__class__.__bases__[-1].__name__}.{func.__name__}` -# # # """ - - -# # # # inner.__name__ = func.__name__ -# # # # inner.__doc__ = func.__doc__ + overwrite_str -# # # # return inner diff --git a/clinguin/utils/attribute_types/__init__.py b/clinguin/utils/attribute_types/__init__.py index 7711caa9..a9262060 100644 --- a/clinguin/utils/attribute_types/__init__.py +++ b/clinguin/utils/attribute_types/__init__.py @@ -1,6 +1,7 @@ """ Module which contains all possible attribute- and callback-types. """ + from .boolean import BooleanType from .child_layout import ChildLayoutType from .color import ColorType diff --git a/clinguin/utils/attribute_types/child_layout.py b/clinguin/utils/attribute_types/child_layout.py index 6ae39990..73154b4b 100644 --- a/clinguin/utils/attribute_types/child_layout.py +++ b/clinguin/utils/attribute_types/child_layout.py @@ -1,6 +1,7 @@ """ Module that contains the ChildLayoutType. """ + from enum import auto from .enum import EnumType diff --git a/clinguin/utils/attribute_types/flex_direction.py b/clinguin/utils/attribute_types/flex_direction.py index e4c2ffca..d77f858b 100644 --- a/clinguin/utils/attribute_types/flex_direction.py +++ b/clinguin/utils/attribute_types/flex_direction.py @@ -1,6 +1,7 @@ """ Module that contains the FlexDirectionType """ + from enum import auto from .enum import EnumType diff --git a/clinguin/utils/attribute_types/font_families.py b/clinguin/utils/attribute_types/font_families.py index 244fc624..87df2f70 100644 --- a/clinguin/utils/attribute_types/font_families.py +++ b/clinguin/utils/attribute_types/font_families.py @@ -2,7 +2,6 @@ Module that contains the FontFamiliesType. """ - from .type import Type from .utils.standard_text_processing import StandardTextProcessing diff --git a/clinguin/utils/attribute_types/font_weight.py b/clinguin/utils/attribute_types/font_weight.py index 4d496380..508ecce8 100644 --- a/clinguin/utils/attribute_types/font_weight.py +++ b/clinguin/utils/attribute_types/font_weight.py @@ -1,6 +1,7 @@ """ Module that contains the FontWeightType. """ + import itertools from enum import auto diff --git a/clinguin/utils/attribute_types/image.py b/clinguin/utils/attribute_types/image.py index 090581e6..f7dd2938 100644 --- a/clinguin/utils/attribute_types/image.py +++ b/clinguin/utils/attribute_types/image.py @@ -1,6 +1,7 @@ """ This module contains the ImageType class. """ + import base64 from .type import Type diff --git a/clinguin/utils/attribute_types/popup_types.py b/clinguin/utils/attribute_types/popup_types.py index 154b33f5..dcbe80c2 100644 --- a/clinguin/utils/attribute_types/popup_types.py +++ b/clinguin/utils/attribute_types/popup_types.py @@ -1,6 +1,7 @@ """ Module that contains the PopupTypesType. """ + from enum import auto from .enum import EnumType diff --git a/clinguin/utils/logger.py b/clinguin/utils/logger.py index 5e6bf14e..67b5832b 100644 --- a/clinguin/utils/logger.py +++ b/clinguin/utils/logger.py @@ -29,10 +29,16 @@ def colored_text(txt, color): def uictl_log(text): + """ + Adds the color of the ui control to the given text for logging + """ return colored_text(text, "CYAN") def domctl_log(text): + """ + Adds the color of the domain control to the given text for logging + """ return colored_text(text, "MAGENTA") @@ -163,6 +169,3 @@ def setup_uvicorn_logger_on_startup(cls, log_arg_dict): cls._add_shell_handler_to_logger(logger, log_arg_dict) if log_arg_dict["file_enabled"]: cls._add_file_handler_to_logger(logger, log_arg_dict, log_file_path) - - def print_domctl_log(self, call): - self.debug(colored_text(call), "CYAN") diff --git a/clinguin/utils/transformer.py b/clinguin/utils/transformer.py index eebed67d..6bcedd7c 100644 --- a/clinguin/utils/transformer.py +++ b/clinguin/utils/transformer.py @@ -1,3 +1,7 @@ +""" +A clingo transformer that checks if files are using a given predicate signature +""" + import clingo.ast as _ast @@ -12,6 +16,9 @@ def __init__(self, name: str, arity: int) -> None: self.contained = False def visit_Function(self, node: _ast.AST) -> _ast.AST: + """ + Visits a function node and checks if it is the predicate signature we are looking for + """ if node.name == self.name and len(node.arguments) == self.arity: self.contained = True return node @@ -20,4 +27,5 @@ def parse_files(self, paths) -> str: """ Parses the files and returns a string with the transformed program. """ + # pylint: disable=unnecessary-lambda _ast.parse_files([str(p) for p in paths], lambda stm: self(stm)) diff --git a/tests/reference_json_output/__init__.py b/tests/reference_json_output/__init__.py index 404069e9..5ee42ece 100644 --- a/tests/reference_json_output/__init__.py +++ b/tests/reference_json_output/__init__.py @@ -33,5 +33,5 @@ BasicTest10.__name__, BasicTest11.__name__, BasicTest12.__name__, - Sudoku.__name__ + Sudoku.__name__, ]