From 51e9764f04da876993a80f6f09910e019eb84446 Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 22 Jun 2021 12:26:43 +0200 Subject: fix issues reported by Codacy --- pyGHDL/dom/NonStandard.py | 5 +++-- pyGHDL/dom/_Utils.py | 2 +- pyGHDL/libghdl/__init__.py | 2 +- pyGHDL/libghdl/errorout.py | 3 --- pyGHDL/libghdl/std_names.py | 2 -- pyGHDL/libghdl/utils.py | 1 - pyGHDL/libghdl/vhdl/elocations.py | 3 --- pyGHDL/libghdl/vhdl/nodes.py | 1 + pyGHDL/libghdl/vhdl/nodes_meta.py | 1 + pyGHDL/lsp/lsp.py | 2 +- pyGHDL/lsp/workspace.py | 14 +++++++------- 11 files changed, 15 insertions(+), 21 deletions(-) (limited to 'pyGHDL') diff --git a/pyGHDL/dom/NonStandard.py b/pyGHDL/dom/NonStandard.py index 9010e392b..4b35e7da2 100644 --- a/pyGHDL/dom/NonStandard.py +++ b/pyGHDL/dom/NonStandard.py @@ -80,8 +80,9 @@ class Design(VHDLModel_Design): self.__ghdl_init() def __ghdl_init(self): - """Initialization: set options and then load libraries.""" - + """ + Initialization: set options and then load libraries. + """ # Initialize libghdl libghdl_finalize() libghdl_initialize() diff --git a/pyGHDL/dom/_Utils.py b/pyGHDL/dom/_Utils.py index 38a85c0c3..2142490e3 100644 --- a/pyGHDL/dom/_Utils.py +++ b/pyGHDL/dom/_Utils.py @@ -59,7 +59,7 @@ def GetIirKindOfNode(node: Iir) -> nodes.Iir_Kind: @export def GetNameOfNode(node: Iir) -> str: - """Return the python string from node :obj:`node` identifier""" + """Return the python string from node :obj:`node` identifier.""" identifier = nodes.Get_Identifier(node) return name_table.Get_Name_Ptr(identifier) diff --git a/pyGHDL/libghdl/__init__.py b/pyGHDL/libghdl/__init__.py index 1477d9361..0d3c75fa1 100644 --- a/pyGHDL/libghdl/__init__.py +++ b/pyGHDL/libghdl/__init__.py @@ -52,7 +52,7 @@ class LibGHDLException(GHDLBaseException): def _get_libghdl_name() -> Path: - """Get the name of the libghdl library (with version and extension)""" + """Get the name of the libghdl library (with version and extension).""" ver = __version__.replace("-", "_").replace(".", "_") ext = {"win32": "dll", "cygwin": "dll", "darwin": "dylib"}.get(sys.platform, "so") return Path("libghdl-{version}.{ext}".format(version=ver, ext=ext)) diff --git a/pyGHDL/libghdl/errorout.py b/pyGHDL/libghdl/errorout.py index a4f034d46..94143b29e 100644 --- a/pyGHDL/libghdl/errorout.py +++ b/pyGHDL/libghdl/errorout.py @@ -5,9 +5,6 @@ from enum import IntEnum, unique from pydecor import export from pyGHDL.libghdl._decorator import BindToLibGHDL -from enum import IntEnum, unique - -from pyGHDL.libghdl import libghdl @export diff --git a/pyGHDL/libghdl/std_names.py b/pyGHDL/libghdl/std_names.py index 256a1c425..b9bdb95d3 100644 --- a/pyGHDL/libghdl/std_names.py +++ b/pyGHDL/libghdl/std_names.py @@ -4,8 +4,6 @@ from enum import IntEnum, unique from pydecor import export -from pyGHDL.libghdl._decorator import BindToLibGHDL - @export class Name: diff --git a/pyGHDL/libghdl/utils.py b/pyGHDL/libghdl/utils.py index e964f3ce3..98e350e03 100644 --- a/pyGHDL/libghdl/utils.py +++ b/pyGHDL/libghdl/utils.py @@ -206,7 +206,6 @@ def declarations_iter(n) -> Generator[Any, None, None]: yield n1 # Handle nested declarations: record elements, physical units, # enumeration literals... - typ = nodes.Get_Type_Definition(n1) for n2 in declarations_iter(n1): yield n2 else: diff --git a/pyGHDL/libghdl/vhdl/elocations.py b/pyGHDL/libghdl/vhdl/elocations.py index c2cda3940..852b7cfea 100644 --- a/pyGHDL/libghdl/vhdl/elocations.py +++ b/pyGHDL/libghdl/vhdl/elocations.py @@ -1,10 +1,7 @@ # Auto generated Python source file from Ada sources # Call 'make' in 'src/vhdl' to regenerate: # -from enum import IntEnum, unique from pydecor import export - -from pyGHDL.libghdl._decorator import BindToLibGHDL from pyGHDL.libghdl import libghdl diff --git a/pyGHDL/libghdl/vhdl/nodes.py b/pyGHDL/libghdl/vhdl/nodes.py index 8e50a35ff..9d44580b4 100644 --- a/pyGHDL/libghdl/vhdl/nodes.py +++ b/pyGHDL/libghdl/vhdl/nodes.py @@ -5,6 +5,7 @@ from enum import IntEnum, unique from pydecor import export from pyGHDL.libghdl._decorator import BindToLibGHDL + from typing import TypeVar from ctypes import c_int32 from pyGHDL.libghdl import libghdl diff --git a/pyGHDL/libghdl/vhdl/nodes_meta.py b/pyGHDL/libghdl/vhdl/nodes_meta.py index 08724ccdf..0ad2b247e 100644 --- a/pyGHDL/libghdl/vhdl/nodes_meta.py +++ b/pyGHDL/libghdl/vhdl/nodes_meta.py @@ -5,6 +5,7 @@ from enum import IntEnum, unique from pydecor import export from pyGHDL.libghdl._decorator import BindToLibGHDL + from pyGHDL.libghdl import libghdl from pyGHDL.libghdl._types import IirKind diff --git a/pyGHDL/lsp/lsp.py b/pyGHDL/lsp/lsp.py index a2598f186..43b8c47c8 100644 --- a/pyGHDL/lsp/lsp.py +++ b/pyGHDL/lsp/lsp.py @@ -117,7 +117,7 @@ class LanguageProtocolServer(object): params = {} try: response = fmethod(**params) - except Exception as e: + except Exception: log.exception( "Caught exception while handling %s with params %s:", method, params ) diff --git a/pyGHDL/lsp/workspace.py b/pyGHDL/lsp/workspace.py index bef20a872..cb392be9b 100644 --- a/pyGHDL/lsp/workspace.py +++ b/pyGHDL/lsp/workspace.py @@ -4,7 +4,7 @@ import json from ctypes import byref import pyGHDL.libghdl as libghdl import pyGHDL.libghdl.errorout_memory as errorout_memory -import pyGHDL.libghdl.flags +import pyGHDL.libghdl.flags as flags import pyGHDL.libghdl.errorout as errorout import pyGHDL.libghdl.files_map as files_map import pyGHDL.libghdl.libraries as libraries @@ -12,7 +12,7 @@ import pyGHDL.libghdl.name_table as name_table import pyGHDL.libghdl.vhdl.nodes as nodes import pyGHDL.libghdl.vhdl.lists as lists import pyGHDL.libghdl.vhdl.std_package as std_package -import pyGHDL.libghdl.vhdl.parse +import pyGHDL.libghdl.vhdl.parse as parse import pyGHDL.libghdl.vhdl.sem_lib as sem_lib import pyGHDL.libghdl.utils as pyutils @@ -44,15 +44,15 @@ class Workspace(object): self._prj = {} self._last_linted_doc = None errorout_memory.Install_Handler() - libghdl.flags.Flag_Elocations.value = True - # libghdl.Flags.Verbose.value = True + flags.Flag_Elocations.value = True + # flags.Verbose.value = True # We do analysis even in case of errors. - libghdl.vhdl.parse.Flag_Parse_Parenthesis.value = True + parse.Flag_Parse_Parenthesis.value = True # Force analysis to get more feedback + navigation even in case # of errors. - libghdl.flags.Flag_Force_Analysis.value = True + flags.Flag_Force_Analysis.value = True # Do not consider analysis order issues. - libghdl.flags.Flag_Elaborate_With_Outdated.value = True + flags.Flag_Elaborate_With_Outdated.value = True libghdl.errorout.Enable_Warning(errorout.Msgid.Warnid_Unused, True) self.read_project() self.set_options_from_project() -- cgit v1.2.3