From 9392f55fb74b8d34eac2ecda00b09f92507ba2ef Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 5 Sep 2014 17:24:41 -0700 Subject: [PATCH] Use a documented constant for the docutils levels Instead of having a implicitly defined constant that doesn't explain why the value was set use a documented frozenset that has the valid docutils messaging levels with links/comments to describe why they are being used. Change-Id: I372c1babfb02c33b5881e2e6a12d464f75d944f7 --- doc8/checks.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/doc8/checks.py b/doc8/checks.py index 4d63fd4..074d35b 100644 --- a/doc8/checks.py +++ b/doc8/checks.py @@ -77,6 +77,14 @@ class CheckValidity(ContentCheck): REPORTS = frozenset(["D000"]) EXT_MATCHER = re.compile(r"(.*)[.]rst", re.I) + # From docutils docs: + # + # Report system messages at or higher than : "info" or "1", + # "warning"/"2" (default), "error"/"3", "severe"/"4", "none"/"5" + # + # See: http://docutils.sourceforge.net/docs/user/config.html#report-level + WARN_LEVELS = frozenset([2, 3, 4]) + # Only used when running in sphinx mode. SPHINX_IGNORES_REGEX = [ re.compile(r'^Unknown interpreted text'), @@ -93,7 +101,7 @@ class CheckValidity(ContentCheck): for error in parsed_file.errors: if error.line is None: continue - if error.level <= 1: + if error.level not in self.WARN_LEVELS: continue ignore = False if self._sphinx_mode: