Skip to content

Commit

Permalink
Merge ecda409 into 8a1cdc1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytelife26 committed May 17, 2021
2 parents 8a1cdc1 + ecda409 commit 5bf5323
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 40 deletions.
11 changes: 4 additions & 7 deletions proselint/checks/uncomparables/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@
attention and expects you to have done the same.
"""
import re
from proselint.tools import memoize
from proselint.tools import existence_check, memoize
import itertools


@memoize
def check(text):
"""Check the text."""
err = "uncomparables.misc"
Expand Down Expand Up @@ -114,9 +113,7 @@ def check(text):
("more", "possible") # FIXME
]

all = [i[0] + r"\s" + i[1] + r"[\W$]" for i in itertools.product(
comparators, uncomparables) if i not in exceptions]
uncomparables = [fr"{i[0]}\s{i[1]}" for i in itertools.product(
comparators, uncomparables) if i not in exceptions]

occ = re.finditer("|".join(all), text.lower())
return [(o.start(), o.end(), err, msg.format(o.group(0)), None)
for o in occ]
return existence_check(text, uncomparables, err, msg, require_padding=True)
4 changes: 2 additions & 2 deletions proselint/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def wrapped(*args, **kwargs):

key = hashlib.sha256(signature).hexdigest()

cache = _get_cache(cachepath)
try:
cache = _get_cache(cachepath)
return cache[key]
except KeyError:
value = f(*args, **kwargs)
Expand Down Expand Up @@ -261,7 +261,7 @@ def lint(input_file, debug=False):
(line, column) = line_and_column(text, start)
if not is_quoted(start, text):
errors += [(check, message, line, column, start, end,
end - start, "warning", replacements)]
end - start, "warning", replacements)]

if len(errors) > options["max_errors"]:
break
Expand Down
28 changes: 0 additions & 28 deletions tests/test_dfw_uncomparables.py

This file was deleted.

18 changes: 15 additions & 3 deletions tests/test_uncomparables.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Tests for uncomparables.misc check."""
"""Test uncomparables.misc"""
from __future__ import absolute_import

from .check import Check

from proselint.checks.uncomparables import misc as chk


Expand All @@ -20,3 +18,17 @@ def test_smoke(self):
"""Basic smoke test for uncomparables.misc."""
assert self.passes("""Smoke phrase with nothing flagged.""")
assert not self.passes("""The item was more unique.""")

def test_sample_phrases(self):
"""Find 'very unique'."""
assert not self.passes("""This sentence is very unique.""")

def test_spaces(self):
"""Handle spacing correctly."""
assert not self.passes("""This sentence is very\nunique.""")
assert not self.passes("""Kind of complete.""")
assert self.passes("""Every perfect instance.""")

def test_constitutional(self):
"""Don't flag exceptions."""
assert self.passes("""A more perfect union.""")

0 comments on commit 5bf5323

Please sign in to comment.