--- a/src/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py Sat Jul 08 12:08:27 2023 +0200 +++ b/src/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py Sat Jul 08 16:20:59 2023 +0200 @@ -157,30 +157,31 @@ errors), the message, a list with arguments for the message) @rtype dict """ - try: - import tomlkit # __IGNORE_WARNING_I10__ + if codestring: + try: + import tomlkit # __IGNORE_WARNING_I10__ - from tomlkit.exceptions import ( # __IGNORE_WARNING_I10__ - KeyAlreadyPresent, - ParseError, - ) - except ImportError: - error = "tomlkit not available. Install it via the PyPI interface." - return [{"error": (file, 0, 0, "", error)}] + from tomlkit.exceptions import ( # __IGNORE_WARNING_I10__ + KeyAlreadyPresent, + ParseError, + ) + except ImportError: + error = "tomlkit not available. Install it via the PyPI interface." + return [{"error": (file, 0, 0, "", error)}] - try: - 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 + try: + 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] + cline = min(len(codestring.splitlines()), int(line)) - 1 + code = codestring.splitlines()[cline] - return [{"error": (file, line, column, code, error)}] - except KeyAlreadyPresent as exc: - return [{"error": (file, 0, 0, "", str(exc))}] + return [{"error": (file, line, column, code, error)}] + except KeyAlreadyPresent as exc: + return [{"error": (file, 0, 0, "", str(exc))}] return [{}]