Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_on_no_newlines(self):
"""Test that lint works on text without a terminal newline."""
assert len(lint(self.text_with_no_newline)) == 1
def test_errors_sorted(self):
"""Test that errors are sorted by line and column number."""
lines_and_cols = [self.extract_line_col(e) for e in lint(self.text)]
assert sorted(lines_and_cols) == lines_and_cols
# Lint the files
num_errors = 0
# Use stdin if no paths were specified
if len(paths) == 0:
filepaths.append('-')
for fp in filepaths:
try:
if fp == '-':
fp = ''
f = sys.stdin
else:
f = click.open_file(
fp, 'r', encoding="utf-8", errors="replace")
errors = lint(f, debug=debug)
num_errors += len(errors)
print_errors(fp, errors, output_json, compact=compact)
except Exception:
traceback.print_exc()
# Return an exit code
close_cache_shelves()
if num_errors > 0:
sys.exit(1)
else:
sys.exit(0)
def worker_function(text):
"""Lint the text using a worker dyno."""
return proselint.tools.lint(text)