Syntax Checker eric7

Tue, 31 May 2022 09:59:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 31 May 2022 09:59:42 +0200
branch
eric7
changeset 9107
8e9525a780ae
parent 9106
287d5afa2dbe
child 9108
19a57544f32c

Syntax Checker
- changed the TOML syntax checker to use 'tomlkit' because 'toml' is no longer maintained

docs/changelog file | annotate | diff | comparison | revisions
eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py file | annotate | diff | comparison | revisions
scripts/install-dependencies.py file | annotate | diff | comparison | revisions
scripts/install.py file | annotate | diff | comparison | revisions
setup.py file | annotate | diff | comparison | revisions
--- a/docs/changelog	Mon May 30 09:51:57 2022 +0200
+++ b/docs/changelog	Tue May 31 09:59:42 2022 +0200
@@ -14,6 +14,9 @@
   -- updated the list of known UF2 capable boards
 - pip Interface
   -- added a filter to the package licenses dialog
+- Syntax Checker
+  -- changed the TOML syntax checker to use 'tomlkit' because 'toml' is no
+     longer maintained
 - Testing
   -- reworked the former unittest interface to allow to support testing
      frameworks other than "unittest"
--- a/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py	Mon May 30 09:51:57 2022 +0200
+++ b/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py	Tue May 31 09:59:42 2022 +0200
@@ -173,19 +173,21 @@
     @rtype dict
     """
     try:
-        import toml
+        import tomlkit
+        from tomlkit.exceptions import ParseError
     except ImportError:
-        error = "toml not available. Install it via the PyPI interface."
+        error = "tomlkit not available. Install it via the PyPI interface."
         return [{'error': (file, 0, 0, '', error)}]
     
     codestring = normalizeCode(codestring)
     
     try:
-        toml.loads(codestring)
-    except toml.TomlDecodeError as exc:
-        line = exc.lineno
-        column = exc.colno
-        error = exc.msg
+        tomlkit.parse(codestring)
+    except ParseError as exc:
+        line = exc.line
+        column = exc.col
+        error = str(exc).split(" at ", 1)[0].strip()
+        # get error message without location
         
         cline = min(len(codestring.splitlines()), int(line)) - 1
         code = codestring.splitlines()[cline]
--- a/scripts/install-dependencies.py	Mon May 30 09:51:57 2022 +0200
+++ b/scripts/install-dependencies.py	Tue May 31 09:59:42 2022 +0200
@@ -45,7 +45,7 @@
         "docutils",
         "Markdown",
         "pyyaml",
-        "toml",
+        "tomlkit",
         "chardet",
         "asttokens",
         "EditorConfig",
--- a/scripts/install.py	Mon May 30 09:51:57 2022 +0200
+++ b/scripts/install.py	Tue May 31 09:59:42 2022 +0200
@@ -1609,7 +1609,7 @@
         "docutils": ("docutils", ""),
         "Markdown": ("markdown", ""),
         "pyyaml": ("yaml", ""),
-        "toml": ("toml", ""),
+        "tomlkit": ("tomlkit", ""),
         "chardet": ("chardet", ""),
         "asttokens": ("asttokens", ""),
         "EditorConfig": ("editorconfig", ""),
--- a/setup.py	Mon May 30 09:51:57 2022 +0200
+++ b/setup.py	Tue May 31 09:59:42 2022 +0200
@@ -347,7 +347,7 @@
         "docutils",
         "Markdown",
         "pyyaml",
-        "toml",
+        "tomlkit",
         "chardet",
         "asttokens",
         "EditorConfig",

eric ide

mercurial