aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorumarcor <unai.martinezcorral@ehu.eus>2021-06-22 19:31:18 +0200
committerumarcor <unai.martinezcorral@ehu.eus>2021-06-23 17:09:44 +0200
commit6e1bbc43fc29528ceaf5d422461206e29e801744 (patch)
treea3273f25e220b2c69869c4c8376f31e8229dbcda
parentc6283d9a9b40c3e9afeba912fcb13aa9d56b9c52 (diff)
downloadghdl-6e1bbc43fc29528ceaf5d422461206e29e801744.tar.gz
ghdl-6e1bbc43fc29528ceaf5d422461206e29e801744.tar.bz2
ghdl-6e1bbc43fc29528ceaf5d422461206e29e801744.zip
fix more codacy issues
-rw-r--r--pyGHDL/libghdl/std_names.py1
-rw-r--r--pyGHDL/libghdl/vhdl/nodes.py3
-rw-r--r--pyGHDL/libghdl/vhdl/tokens.py2
-rw-r--r--pyGHDL/lsp/document.py2
-rw-r--r--pyGHDL/lsp/lsp.py6
-rw-r--r--pyGHDL/lsp/lsptools.py4
-rw-r--r--pyGHDL/lsp/references.py4
-rw-r--r--pyGHDL/lsp/workspace.py22
-rwxr-xr-xscripts/pnodes.py2
-rwxr-xr-xscripts/pnodespy.py15
-rw-r--r--testsuite/gna/issue283/example.py2
11 files changed, 32 insertions, 31 deletions
diff --git a/pyGHDL/libghdl/std_names.py b/pyGHDL/libghdl/std_names.py
index b9bdb95d3..7f27a0116 100644
--- a/pyGHDL/libghdl/std_names.py
+++ b/pyGHDL/libghdl/std_names.py
@@ -1,7 +1,6 @@
# Auto generated Python source file from Ada sources
# Call 'make' in 'src/vhdl' to regenerate:
#
-from enum import IntEnum, unique
from pydecor import export
diff --git a/pyGHDL/libghdl/vhdl/nodes.py b/pyGHDL/libghdl/vhdl/nodes.py
index 1a4cf043f..e4527a1d6 100644
--- a/pyGHDL/libghdl/vhdl/nodes.py
+++ b/pyGHDL/libghdl/vhdl/nodes.py
@@ -8,7 +8,6 @@ from pyGHDL.libghdl._decorator import BindToLibGHDL
from typing import TypeVar
from ctypes import c_int32
-from pyGHDL.libghdl import libghdl
from pyGHDL.libghdl._types import (
Iir,
IirKind,
@@ -1802,7 +1801,7 @@ class Iir_Predefined(IntEnum):
@export
@BindToLibGHDL("vhdl__nodes__get_kind")
def Get_Kind(node: Iir) -> IirKind:
- """Get node kind"""
+ """Get node kind."""
@export
diff --git a/pyGHDL/libghdl/vhdl/tokens.py b/pyGHDL/libghdl/vhdl/tokens.py
index 4923ea80f..c7e8b9878 100644
--- a/pyGHDL/libghdl/vhdl/tokens.py
+++ b/pyGHDL/libghdl/vhdl/tokens.py
@@ -4,8 +4,6 @@
from enum import IntEnum, unique
from pydecor import export
-from pyGHDL.libghdl._decorator import BindToLibGHDL
-
@export
@unique
diff --git a/pyGHDL/lsp/document.py b/pyGHDL/lsp/document.py
index a6f9ae217..d60f216d4 100644
--- a/pyGHDL/lsp/document.py
+++ b/pyGHDL/lsp/document.py
@@ -146,7 +146,7 @@ class Document(object):
return tree
def parse_document(self):
- """Parse a document and put the units in the library"""
+ """Parse a document and put the units in the library."""
assert self._tree == nodes.Null_Iir
tree = sem_lib.Load_File(self._fe)
if tree == nodes.Null_Iir:
diff --git a/pyGHDL/lsp/lsp.py b/pyGHDL/lsp/lsp.py
index 43b8c47c8..d76c04616 100644
--- a/pyGHDL/lsp/lsp.py
+++ b/pyGHDL/lsp/lsp.py
@@ -162,7 +162,7 @@ class LanguageProtocolServer(object):
self.conn.write(output)
def notify(self, method, params):
- """Send a notification"""
+ """Send a notification."""
body = {
"jsonrpc": "2.0",
"method": method,
@@ -171,7 +171,7 @@ class LanguageProtocolServer(object):
self.write_output(body)
def send_request(self, method, params):
- """Send a request"""
+ """Send a request."""
self._next_id += 1
body = {
"jsonrpc": "2.0",
@@ -182,7 +182,7 @@ class LanguageProtocolServer(object):
self.write_output(body)
def shutdown(self):
- """Prepare to shutdown the server"""
+ """Prepare to shutdown the server."""
self.running = False
def show_message(self, typ, message):
diff --git a/pyGHDL/lsp/lsptools.py b/pyGHDL/lsp/lsptools.py
index 648f0a8c0..29e0b3292 100644
--- a/pyGHDL/lsp/lsptools.py
+++ b/pyGHDL/lsp/lsptools.py
@@ -5,7 +5,7 @@ from . import lsp
def lsp2json():
- "Utility that transforms lsp log file to a JSON list"
+ """Utility that transforms lsp log file to a JSON list."""
conn = lsp.LSPConn(sys.stdin.buffer, sys.stdout.buffer)
ls = lsp.LanguageProtocolServer(None, conn)
res = []
@@ -18,7 +18,7 @@ def lsp2json():
def json2lsp():
- "Utility that transform a JSON list to an lsp file"
+ """Utility that transform a JSON list to an lsp file."""
res = json.load(sys.stdin)
conn = lsp.LSPConn(sys.stdin.buffer, sys.stdout.buffer)
ls = lsp.LanguageProtocolServer(None, conn)
diff --git a/pyGHDL/lsp/references.py b/pyGHDL/lsp/references.py
index c7d0f730d..44a5f8c13 100644
--- a/pyGHDL/lsp/references.py
+++ b/pyGHDL/lsp/references.py
@@ -18,7 +18,7 @@ def find_def_chain(first, loc):
def find_def(n, loc):
- "Return the node at location :param loc:, or None if not under :param n:"
+ """Return the node at location :param loc:, or None if not under :param n:."""
if n == nodes.Null_Iir:
return None
k = nodes.Get_Kind(n)
@@ -86,7 +86,7 @@ def find_def(n, loc):
def goto_definition(n, loc):
- "Return the declaration (as a node) under :param loc: or None"
+ """Return the declaration (as a node) under :param loc: or None."""
ref = find_def(n, loc)
log.debug("for loc %u found node %s", loc, ref)
if ref is None:
diff --git a/pyGHDL/lsp/workspace.py b/pyGHDL/lsp/workspace.py
index cb392be9b..55d4cbe85 100644
--- a/pyGHDL/lsp/workspace.py
+++ b/pyGHDL/lsp/workspace.py
@@ -23,7 +23,7 @@ log = logging.getLogger(__name__)
class ProjectError(Exception):
- "Exception raised in case of unrecoverable error in the project file."
+ """Exception raised in case of unrecoverable error in the project file."""
def __init__(self, msg):
super().__init__()
@@ -110,8 +110,11 @@ class Workspace(object):
return res
def get_document(self, doc_uri):
- """Get a document from :param doc_uri: Note that the document may not exist,
- and this function may return None."""
+ """
+ Get a document from :param doc_uri:
+
+ Note that the document may not exist, and this function may return None.
+ """
return self._docs.get(doc_uri)
def put_document(self, doc_uri, source, version=None):
@@ -126,8 +129,11 @@ class Workspace(object):
return doc
def sfe_to_document(self, sfe):
- """Get the document correspond to :param sfe: source file.
- Can create the document if needed."""
+ """
+ Get the document correspond to :param sfe: source file.
+
+ Can create the document if needed.
+ """
assert sfe != 0
doc = self._fe_map.get(sfe, None)
if doc is None:
@@ -288,7 +294,7 @@ class Workspace(object):
self.publish_diagnostics(doc.uri, [])
def obsolete_dependent_units(self, unit, antideps):
- """Obsolete units that depends of :param unit:"""
+ """Obsolete units that depends of :param unit:."""
udeps = antideps.get(unit, None)
if udeps is None:
# There are no units.
@@ -375,7 +381,7 @@ class Workspace(object):
)
def declaration_to_location(self, decl):
- "Convert declaration :param decl: to an LSP Location"
+ """Convert declaration :param decl: to an LSP Location."""
decl_loc = nodes.Get_Location(decl)
if decl_loc == std_package.Std_Location.value:
# There is no real file for the std.standard package.
@@ -472,7 +478,7 @@ class Workspace(object):
}
def compute_anti_dependences(self):
- """Return a dictionnary of anti dependencies for design unit"""
+ """Return a dictionnary of anti dependencies for design unit."""
res = {}
lib = libraries.Get_Libraries_Chain()
while lib != nodes.Null_Iir:
diff --git a/scripts/pnodes.py b/scripts/pnodes.py
index 94adb01fd..f260c4b1a 100755
--- a/scripts/pnodes.py
+++ b/scripts/pnodes.py
@@ -473,7 +473,7 @@ def gen_choices(choices):
print(" =>")
-def gen_get_format(formats, nodes, kinds):
+def gen_get_format(formats, nodes, kinds=None):
"""Generate the Get_Format function."""
print(" function Get_Format (Kind : " + type_name + ") " + "return Format_Type is")
print(" begin")
diff --git a/scripts/pnodespy.py b/scripts/pnodespy.py
index f443d36c5..1f016a82d 100755
--- a/scripts/pnodespy.py
+++ b/scripts/pnodespy.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-"""Like pnodes but output for Python"""
+"""Like pnodes but output for Python."""
from __future__ import print_function
@@ -65,7 +65,7 @@ def do_iirs_subprg():
@export
@BindToLibGHDL("{classname}__get_kind")
def Get_Kind(node: Iir) -> IirKind:
- \"\"\"Get node kind\"\"\"
+ \"\"\"Get node kind.\"\"\"
@export
@BindToLibGHDL("{classname}__get_location")
@@ -84,13 +84,13 @@ def do_iirs_subprg():
@export
@BindToLibGHDL("{classname}__get_{kname_lower}")
def Get_{kname}(obj: Iir) -> {rtype}:
- \"\"\"{gettercomment}\"\"\"
+ \"\"\"\"\"\"
@export
@BindToLibGHDL("{classname}__set_{kname_lower}")
def Set_{kname}(obj: Iir, value: {rtype}) -> None:
- \"\"\"{settercomment}\"\"\"
+ \"\"\"\"\"\"
""").format(kname=k.name, kname_lower=k.name.lower(), rtype=rtype,
- libname=libname, classname=classname, gettercomment="", settercomment="")
+ libname=libname, classname=classname)
)
@@ -191,7 +191,6 @@ def do_libghdl_nodes():
print(dedent("""\
from typing import TypeVar
from ctypes import c_int32
- from pyGHDL.libghdl import libghdl
from pyGHDL.libghdl._types import (
Iir,
IirKind,
@@ -334,7 +333,7 @@ def do_libghdl_names():
val_max = max(val_max, val)
dict[name_def] = val
res.append((name_def, val))
- print_file_header(includeBindToLibGHDL=False)
+ print_file_header(includeIntEnumUnique=False, includeBindToLibGHDL=False)
print(dedent("""
@export
@@ -350,7 +349,7 @@ def do_libghdl_names():
def do_libghdl_tokens():
- print_file_header()
+ print_file_header(includeBindToLibGHDL=False)
read_enum("vhdl-tokens.ads", "Token_Type", "Tok_", "Tok")
diff --git a/testsuite/gna/issue283/example.py b/testsuite/gna/issue283/example.py
index d4472dcb9..9c3b21d5d 100644
--- a/testsuite/gna/issue283/example.py
+++ b/testsuite/gna/issue283/example.py
@@ -4,7 +4,7 @@ from cocotb.triggers import Timer
@cocotb.test()
def test_transaction(dut):
-
+
yield Timer(1)
dut._log.info("%d" % dut.s_test)