From 51e9764f04da876993a80f6f09910e019eb84446 Mon Sep 17 00:00:00 2001
From: umarcor <unai.martinezcorral@ehu.eus>
Date: Tue, 22 Jun 2021 12:26:43 +0200
Subject: fix issues reported by Codacy

---
 libraries/openieee/build_1164.py       | 65 +++++++++++++++++-----------------
 libraries/openieee/build_numeric.py    | 23 ++++++------
 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 ++++----
 scripts/pnodespy.py                    | 31 +++++++++-------
 testsuite/gna/issue43/run.py           | 12 ++-----
 testsuite/pyunit/libghdl/Initialize.py |  4 +--
 testsuite/pyunit/lsp/LanguageServer.py |  3 +-
 17 files changed, 81 insertions(+), 93 deletions(-)

diff --git a/libraries/openieee/build_1164.py b/libraries/openieee/build_1164.py
index 40a7ba7e2..bab095285 100755
--- a/libraries/openieee/build_1164.py
+++ b/libraries/openieee/build_1164.py
@@ -36,7 +36,7 @@ ux01_map = { 'U': 'U',
              '1': '1', 'H': '1' }
 
 def sl_and(a,b):
-    """and definition"""
+    """'and' definition."""
     na = ux01_map[a]
     nb = ux01_map[b]
     if na == '0' or nb == '0':
@@ -48,7 +48,7 @@ def sl_and(a,b):
     return '1'
 
 def sl_not(a):
-    """not definition"""
+    """'not' definition."""
     na = ux01_map[a]
     if na == 'U':
         return 'U'
@@ -60,11 +60,11 @@ def sl_not(a):
         return '1'
 
 def sl_or(a,b):
-    "or definition"
+    """'or' definition."""
     return sl_not(sl_and (sl_not(a), sl_not(b)))
 
 def sl_xor(a,b):
-    "xor definition"
+    """'xor' definition."""
     return sl_or(sl_and(a, sl_not(b)),
                  sl_and(sl_not(a), b))
 
@@ -72,11 +72,11 @@ def sl_xor(a,b):
 out=sys.stdout
 
 def w(s):
-    "Write S to the output"
+    """Write S to the output."""
     out.write(s)
 
 def gen_log_table2(name, func):
-    "Generate a logic table for binary operator NAME using its model FUNC"
+    """Generate a logic table for binary operator NAME using its model FUNC."""
     w("""
   constant {0}_table : table_2d :=
   --  UX01ZWLH-
@@ -95,7 +95,7 @@ def gen_log_table2(name, func):
     w(');\n')
 
 def gen_log_table1(name, func):
-    "Generate a logic table for unary operator NAME using its model FUNC"
+    """Generate a logic table for unary operator NAME using its model FUNC."""
     w("""
   constant {0}_table : table_1d :=
   --  UX01ZWLH-
@@ -106,7 +106,7 @@ def gen_log_table1(name, func):
     w('";\n')
 
 def disp_tables(version):
-    "Generate logic tables"
+    """Generate logic tables."""
     gen_log_table2("and", sl_and)
     gen_log_table2("nand", lambda a,b : sl_not(sl_and(a, b)))
     gen_log_table2("or", sl_or)
@@ -119,7 +119,7 @@ def disp_tables(version):
 vec_types = ['ulogic', 'logic']
 
 def disp_scalar_binary(fun):
-    "Generate scalar binary function body"
+    """Generate scalar binary function body."""
     w("""
   function "{0}" (l : std_ulogic; r : std_ulogic) return UX01 is
   begin
@@ -127,7 +127,7 @@ def disp_scalar_binary(fun):
   end "{0}";\n""".format(fun))
 
 def disp_scalar_unary(fun):
-    "Generate scalar unary function body"
+    """Generate scalar unary function body."""
     w("""
   function "{0}" (l : std_ulogic) return UX01 is
   begin
@@ -135,7 +135,7 @@ def disp_scalar_unary(fun):
   end "{0}";\n""".format(fun))
 
 def disp_vec_binary(func, typ):
-    "Generate vector binary function body"
+    """Generate vector binary function body."""
     w("""
   function "{0}" (l, r : std_{1}_vector) return std_{1}_vector
   is
@@ -157,7 +157,7 @@ def disp_vec_binary(func, typ):
   end "{0}";\n""".format(func, typ))
 
 def disp_vec_unary(func, typ):
-    "Generate vector unary function body"
+    """Generate vector unary function body."""
     w("""
   function "{0}" (l : std_{1}_vector) return std_{1}_vector
   is
@@ -172,7 +172,7 @@ def disp_vec_unary(func, typ):
   end "{0}";\n""".format(func, typ))
 
 def disp_scal_vec_binary(func, typ):
-    "Generate scalar-vector binary function body"
+    """Generate scalar-vector binary function body."""
     w("""
   function "{0}" (l : std_{1}_vector; r : std_{1})
     return std_{1}_vector
@@ -188,7 +188,7 @@ def disp_scal_vec_binary(func, typ):
   end "{0}";\n""".format(func, typ))
 
 def disp_vec_scal_binary(func, typ):
-    "Generate vector-scalar binary function body"
+    """Generate vector-scalar binary function body."""
     w("""
   function "{0}" (l : std_{1}; r : std_{1}_vector)
     return std_{1}_vector
@@ -204,7 +204,7 @@ def disp_vec_scal_binary(func, typ):
   end "{0}";\n""".format(func, typ))
 
 def disp_vec_reduction(func, typ):
-    "Generate reduction function body"
+    """Generate reduction function body."""
     init = '1' if func in ['and', 'nand'] else '0'
     w("""
   function "{0}" (l : std_{1}_vector) return std_{1}
@@ -225,7 +225,7 @@ def gen_shift(is_left, plus, minus):
     w("      " + s.format(plus, minus))
 
 def disp_shift_funcs(func, typ):
-    "Generate shift functions"
+    """Generate shift functions."""
     w("""
   function "{0}" (l : std_{1}_vector; r : integer)
     return std_{1}_vector
@@ -255,7 +255,7 @@ def gen_rot(is_left, plus, minus):
         w('\n')
 
 def disp_rot_funcs(func, typ):
-    "Generate rotation functions"
+    """Generate rotation functions."""
     w("""
   function "{0}" (l : std_{1}_vector; r : integer)
     return std_{1}_vector
@@ -271,10 +271,10 @@ def disp_rot_funcs(func, typ):
     gen_rot(func != "rol", '-', '+')
     w("""    end if;
     return res;
-  end "{0}";\n""".format(func, typ))
+  end "{0}";\n""".format(func))
 
 def disp_all_log_funcs(version):
-    "Generate all function bodies for logic operators"
+    """Generate all function bodies for logic operators."""
     for f in binary_funcs:
         disp_scalar_binary(f)
     disp_scalar_unary("not")
@@ -294,7 +294,7 @@ def disp_all_log_funcs(version):
             disp_rot_funcs("ror", v)
 
 def disp_sv_to_bv_conv(typ):
-    "Generate logic vector to bit vector function body"
+    """Generate logic vector to bit vector function body."""
     w("""
   function to_bitvector (s : std_{0}_vector; xmap : bit := '0')
     return bit_vector
@@ -320,7 +320,7 @@ def disp_sv_to_bv_conv(typ):
   end to_bitvector;\n""".format(typ))
 
 def disp_bv_to_sv_conv(typ):
-    "Generate bit vector to logic vector function body"
+    """Generate bit vector to logic vector function body."""
     w("""
   function to_std{0}vector (b : bit_vector) return std_{0}_vector is
     subtype res_range is natural range b'length - 1 downto 0;
@@ -334,7 +334,7 @@ def disp_bv_to_sv_conv(typ):
   end to_std{0}vector;\n""".format(typ))
 
 def disp_sv_to_sv_conv(s,d):
-    "Generate logic vector to logic vector function body"
+    """Generate logic vector to logic vector function body."""
     w("""
   function to_std{1}vector (s : std_{0}_vector) return std_{1}_vector
   is
@@ -344,7 +344,7 @@ def disp_sv_to_sv_conv(s,d):
   end to_std{1}vector;\n""".format(s,d))
 
 def disp_all_conv_funcs(version):
-    "Generate conversion function bodies"
+    """Generate conversion function bodies."""
     for v in vec_types:
         disp_sv_to_bv_conv(v)
     for v in vec_types:
@@ -355,7 +355,7 @@ def disp_all_conv_funcs(version):
     disp_sv_to_sv_conv('ulogic', 'logic')
 
 def disp_conv_vec_vec(typ, v):
-    "Generate function body for vector conversion"
+    """Generate function body for vector conversion."""
     utyp = typ.upper();
     w("""
   function to_{1} (s : std_{2}_vector) return std_{2}_vector
@@ -371,7 +371,7 @@ def disp_conv_vec_vec(typ, v):
   end to_{1};\n""".format(typ, utyp, v))
 
 def disp_conv_std(typ):
-    "Generate function body for scalar conversion"
+    """Generate function body for scalar conversion."""
     utyp = typ.upper();
     w("""
   function to_{1} (s : std_ulogic) return {1} is
@@ -380,7 +380,7 @@ def disp_conv_std(typ):
   end to_{1};\n""".format(typ, utyp))
 
 def disp_conv_bv_vec(typ, v):
-    "Generate function body for bit vector conversion"
+    """Generate function body for bit vector conversion."""
     utyp = typ.upper();
     w("""
   function to_{0} (b : bit_vector) return std_{1}_vector
@@ -396,16 +396,15 @@ def disp_conv_bv_vec(typ, v):
   end to_{0};\n""".format(utyp, v))
 
 def disp_conv_b_t(typ):
-    "Generate function body for bit conversion"
-    utyp = typ.upper();
+    """Generate function body for bit conversion."""
     w("""
-  function to_{1} (b : bit) return {1} is
+  function to_{0} (b : bit) return {0} is
   begin
     return bit_to_x01 (b);
-  end to_{1};\n""".format(typ, utyp))
+  end to_{0};\n""".format(typ.upper()))
 
 def disp_conv_01():
-    "Generate to_01 bodies"
+    """Generate to_01 bodies."""
     w("""
   function to_01 (s : std_{0}_vector; xmap : std_ulogic := '0')
     return std_{0}_vector
@@ -463,7 +462,7 @@ def disp_cond():
   end "??";\n""")
 
 def disp_all_norm_funcs(version):
-    "Generate all function bodies for conversion"
+    """Generate all function bodies for conversion."""
     if version >= V08:
         disp_conv_01()
     for typ in [ "x01", "x01z", "ux01" ]:
@@ -477,7 +476,7 @@ def disp_all_norm_funcs(version):
         disp_cond()
 
 def disp_all_isx_funcs(version):
-    "Generate all function bodies for isx functions"
+    """Generate all function bodies for isx functions."""
     for v in vec_types:
         w("""
   function is_X (s : std_{0}_vector) return boolean is
diff --git a/libraries/openieee/build_numeric.py b/libraries/openieee/build_numeric.py
index df6c8515f..b9348d2a7 100755
--- a/libraries/openieee/build_numeric.py
+++ b/libraries/openieee/build_numeric.py
@@ -21,7 +21,6 @@
 #  along with GHDL; see the file COPYING.md.  If not see
 #  <http://www.gnu.org/licenses/>.
 
-import re
 import sys
 
 # My python 'style' and knowledge is basic...  Do not hesitate to comment.
@@ -43,7 +42,7 @@ v93=False
 out=sys.stdout
 
 def w(s):
-    "Write S to the output"
+    """Write S to the output."""
     out.write(s)
 
 def logic_type():
@@ -53,7 +52,7 @@ def logic_undef():
     return logic_undefs[logic]
 
 def disp_vec_binary(func, typ):
-    "Generate the body of a vector binary logic function"
+    """Generate the body of a vector binary logic function."""
     res = """
   function "{0}" (l, r : {1}) return {1}
   is
@@ -115,7 +114,7 @@ def extract_extend_bit(name,typ):
     return res.format(name)
 
 def disp_vec_vec_binary(func, typ):
-    "Generate vector binary function body"
+    """Generate vector binary function body."""
     res = """
   function "{0}" (l, r : {1}) return {1}
   is
@@ -219,7 +218,7 @@ def create_vec_int_dict(func, left, right):
     return dic
 
 def disp_vec_int_binary(func, left, right):
-    "Generate vector binary function body"
+    """Generate vector binary function body."""
     dic = create_vec_int_dict(func, left, right)
     res = """
   function "{func}" (l : {ltype}; r : {rtype}) return {vtype}
@@ -266,7 +265,7 @@ def disp_vec_int_binary(func, left, right):
     w(res.format (**dic))
 
 def disp_vec_int_gcompare(func, left, right):
-    "Generate comparison function"
+    """Generate comparison function."""
     dic = create_vec_int_dict(func, left, right)
     res = """
   function {func} (l : {ltype}; r : {rtype}) return compare_type
@@ -320,7 +319,7 @@ def disp_vec_int_gcompare(func, left, right):
     w(res.format (**dic))
 
 def disp_vec_int_compare(func, left, right):
-    "Generate comparison function"
+    """Generate comparison function."""
     dic = create_vec_int_dict(func, left, right)
     res = """
   function "{func}" (l : {ltype}; r : {rtype}) return boolean
@@ -366,7 +365,7 @@ def disp_vec_int_compare(func, left, right):
     w(res.format (**dic))
 
 def disp_vec_vec_gcompare(func, typ):
-    "Generate comparison function"
+    """Generate comparison function."""
     res = """
   function {func} (l, r : {typ}) return compare_type
   is
@@ -418,7 +417,7 @@ def disp_vec_vec_gcompare(func, typ):
     w(res.format (func=func, typ=typ, logic=logic_type()))
 
 def disp_vec_vec_compare(func, typ):
-    "Generate comparison function"
+    """Generate comparison function."""
     res = """
   function "{func}" (l, r : {typ}) return boolean
   is
@@ -451,7 +450,7 @@ def disp_vec_vec_compare(func, typ):
     w(res.format (func=func, typ=typ))
 
 def disp_vec_not(typ):
-    "Generate vector binary function body"
+    """Generate vector binary function body."""
     w("""
   function "not" (l : {0}) return {0}
   is
@@ -1010,7 +1009,7 @@ def disp_vec_int_sdiv(func):
     w(res.format(func=func))
 
 def disp_all_log_funcs():
-    "Generate all function bodies for logic operators"
+    """Generate all function bodies for logic operators."""
     for t in vec_types:
         disp_resize(t)
     for v in vec_types:
@@ -1076,7 +1075,7 @@ def disp_all_match_funcs():
     disp_match('SIGNED');
 
 def disp_all_arith_funcs():
-    "Generate all function bodies for logic operators"
+    """Generate all function bodies for logic operators."""
     for op in ['+', '-']:
         disp_vec_vec_binary(op, "UNSIGNED")
         disp_vec_vec_binary(op, "SIGNED")
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()
diff --git a/scripts/pnodespy.py b/scripts/pnodespy.py
index b4209bc90..1f95cac4d 100755
--- a/scripts/pnodespy.py
+++ b/scripts/pnodespy.py
@@ -30,18 +30,27 @@ def print_enum(name, vals):
         print("    {0} = {1}".format(k, n))
 
 
-def print_file_header():
+def print_file_header(includeIntEnumunique=True,includeBindToLibGHDL=True):
     print(dedent("""\
             # 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
         """), end=''
     )
 
+    if includeIntEnumunique:
+        print("from enum import IntEnum, unique")
+
+    print("from pydecor import export")
+
+    if includeBindToLibGHDL:
+        print(dedent("""\
+
+                from pyGHDL.libghdl._decorator import BindToLibGHDL
+
+            """), end=''
+        )
+
 
 def do_class_kinds():
     print_enum(pnodes.prefix_name.rstrip("_"), pnodes.kinds)
@@ -97,7 +106,7 @@ def do_iirs_subprg():
 
 def do_libghdl_elocations():
     classname = "vhdl__elocations"
-    print_file_header()
+    print_file_header(includeIntEnumunique=False, includeBindToLibGHDL=False)
     print("from pyGHDL.libghdl import libghdl")
     print()
     for k in pnodes.funcs:
@@ -147,7 +156,7 @@ def do_class_fields():
 
 
 def read_enum(filename, type_name, prefix, class_name, g=lambda m: m.group(1)):
-    """Read an enumeration declaration from :param filename:"""
+    """Read an enumeration declaration from :param filename:."""
     pat_decl = re.compile(r"   type {0} is$".format(type_name))
     pat_enum = re.compile(r"      {0}(\w+),?( *-- .*)?$".format(prefix))
     pat_comment = re.compile(r" *-- .*$")
@@ -183,7 +192,7 @@ def read_enum(filename, type_name, prefix, class_name, g=lambda m: m.group(1)):
 
 
 def read_spec_enum(type_name, prefix, class_name):
-    """Read an enumeration declaration from iirs.ads"""
+    """Read an enumeration declaration from iirs.ads."""
     read_enum(pnodes.kind_file, type_name, prefix, class_name)
 
 
@@ -335,7 +344,7 @@ def do_libghdl_names():
             val_max = max(val_max, val)
             dict[name_def] = val
             res.append((name_def, val))
-    print_file_header()
+    print_file_header(includeBindToLibGHDL=False)
     print(dedent("""
 
         @export
@@ -358,10 +367,6 @@ def do_libghdl_tokens():
 def do_libghdl_errorout():
     print_file_header()
     print(dedent("""\
-        from enum import IntEnum, unique
-
-        from pyGHDL.libghdl import libghdl
-
         @export
         @BindToLibGHDL("errorout__enable_warning")
         def Enable_Warning(Id: int, Enable: bool) -> None:
diff --git a/testsuite/gna/issue43/run.py b/testsuite/gna/issue43/run.py
index f1cb5ec01..d37c1cbaa 100644
--- a/testsuite/gna/issue43/run.py
+++ b/testsuite/gna/issue43/run.py
@@ -1,14 +1,6 @@
-import os
-import sys
-from string import join
 from vunit import VUnit
 
-
-
-# Create VUnit instance by parsing command line arguments
 vu = VUnit.from_argv()
 vu.add_com()
-lib = vu.add_library("lib")
-lib.add_source_files("*.vhd")
-
-vu.main()
\ No newline at end of file
+vu.add_library("lib").add_source_files("*.vhd")
+vu.main()
diff --git a/testsuite/pyunit/libghdl/Initialize.py b/testsuite/pyunit/libghdl/Initialize.py
index 4d5bb521a..369faee07 100644
--- a/testsuite/pyunit/libghdl/Initialize.py
+++ b/testsuite/pyunit/libghdl/Initialize.py
@@ -18,11 +18,11 @@ class Instantiate(TestCase):
 
 	@staticmethod
 	def getIdentifier(node):
-		"""Return the Python string from node :obj:`node` identifier"""
+		"""Return the Python string from node :obj:`node` identifier."""
 		return name_table.Get_Name_Ptr(nodes.Get_Identifier(node))
 
 	def test_InitializeGHDL(self) -> None:
-		"""Initialization: set options and then load libaries"""
+		"""Initialization: set options and then load libaries."""
 		libghdl.initialize()
 
 		# Print error messages on the console.
diff --git a/testsuite/pyunit/lsp/LanguageServer.py b/testsuite/pyunit/lsp/LanguageServer.py
index 36ee6da2a..c1bcf1898 100644
--- a/testsuite/pyunit/lsp/LanguageServer.py
+++ b/testsuite/pyunit/lsp/LanguageServer.py
@@ -1,5 +1,4 @@
 import os
-import string
 from sys import executable
 from io import BytesIO
 from json import load as json_load, loads as json_loads, dumps as json_dumps
@@ -7,7 +6,7 @@ from pathlib import Path
 from urllib.parse import quote
 from subprocess import run as subprocess_run, PIPE
 from typing import Optional
-from unittest import TestCase, skip
+from unittest import TestCase
 
 from pyGHDL.lsp.lsp import LanguageProtocolServer, LSPConn
 
-- 
cgit v1.2.3