Skip to content

Commit

Permalink
Quality: Have error exit code if spelling problems are found.
Browse files Browse the repository at this point in the history
* We didn't pass the exit code from codespell on, with this we
  can consider using it on our CI.
  • Loading branch information
kayhayen committed Dec 25, 2020
1 parent 0e1f250 commit 3846e4d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions nuitka/tools/quality/codespell/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def resolveShellPatternToFilenames(pattern):
return glob.glob(pattern)


def codespell(filenames, verbose, write):
def runCodespell(filenames, verbose, write):
if verbose:
my_print("Consider", " ".join(filenames))

command = ["codespell", "-I", "misc/codespell-ignore.txt"]
command = ["codespell", "-f", "-I", "misc/codespell-ignore.txt"]
if write:
command.append("-w")
command += filenames
Expand Down Expand Up @@ -76,6 +76,7 @@ def main():

parser.add_option(
"--write",
"-w",
action="store_true",
dest="write",
default=False,
Expand Down Expand Up @@ -114,7 +115,16 @@ def main():
if not filenames:
sys.exit("No files found.")

codespell(filenames=filenames, verbose=options.verbose, write=options.write)
result = runCodespell(
filenames=filenames, verbose=options.verbose, write=options.write
)

if result:
my_print("OK.")
else:
sys.exit(
"\nError, please correct the spelling problems found or extend 'misc/codespell-ignore.txt' if applicable."
)


if __name__ == "__main__":
Expand Down

0 comments on commit 3846e4d

Please sign in to comment.