diff options
Diffstat (limited to 'gitlint/lint.py')
-rw-r--r-- | gitlint/lint.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/gitlint/lint.py b/gitlint/lint.py index 6ef7174..4b6c8a3 100644 --- a/gitlint/lint.py +++ b/gitlint/lint.py @@ -2,13 +2,12 @@ import logging from gitlint import rules as gitlint_rules from gitlint import display -from gitlint.utils import ustr LOG = logging.getLogger(__name__) logging.basicConfig() -class GitLinter(object): +class GitLinter: """ Main linter class. This is where rules actually get applied. See the lint() method. """ def __init__(self, config): @@ -70,7 +69,7 @@ class GitLinter(object): def lint(self, commit): """ Lint the last commit in a given git context by applying all ignore, title, body and commit rules. """ LOG.debug("Linting commit %s", commit.sha or "[SHA UNKNOWN]") - LOG.debug("Commit Object\n" + ustr(commit)) + LOG.debug("Commit Object\n" + str(commit)) # Apply config rules for rule in self.configuration_rules: @@ -79,8 +78,8 @@ class GitLinter(object): # Skip linting if this is a special commit type that is configured to be ignored ignore_commit_types = ["merge", "squash", "fixup", "revert"] for commit_type in ignore_commit_types: - if getattr(commit, "is_{0}_commit".format(commit_type)) and \ - getattr(self.config, "ignore_{0}_commits".format(commit_type)): + if getattr(commit, f"is_{commit_type}_commit") and \ + getattr(self.config, f"ignore_{commit_type}_commits"): return [] violations = [] @@ -99,10 +98,9 @@ class GitLinter(object): """ Print a given set of violations to the standard error output """ for v in violations: line_nr = v.line_nr if v.line_nr else "-" - self.display.e(u"{0}: {1}".format(line_nr, v.rule_id), exact=True) - self.display.ee(u"{0}: {1} {2}".format(line_nr, v.rule_id, v.message), exact=True) + self.display.e(f"{line_nr}: {v.rule_id}", exact=True) + self.display.ee(f"{line_nr}: {v.rule_id} {v.message}", exact=True) if v.content: - self.display.eee(u"{0}: {1} {2}: \"{3}\"".format(line_nr, v.rule_id, v.message, v.content), - exact=True) + self.display.eee(f"{line_nr}: {v.rule_id} {v.message}: \"{v.content}\"", exact=True) else: - self.display.eee(u"{0}: {1} {2}".format(line_nr, v.rule_id, v.message), exact=True) + self.display.eee(f"{line_nr}: {v.rule_id} {v.message}", exact=True) |