diff --git a/.pylintrc b/.pylintrc index 294dfd0..f301cee 100644 --- a/.pylintrc +++ b/.pylintrc @@ -4,7 +4,6 @@ disable= missing-docstring, invalid-name, unused-argument, - no-self-use, useless-object-inheritance, too-many-instance-attributes, too-few-public-methods, @@ -17,3 +16,4 @@ disable= dangerous-default-value, import-error, fixme, + consider-using-f-string, diff --git a/saltlint/config.py b/saltlint/config.py index be165f8..0b72acf 100644 --- a/saltlint/config.py +++ b/saltlint/config.py @@ -26,7 +26,7 @@ def __init__(self, options={}): # Read the file contents if os.path.exists(file): - with open(file, 'r') as f: + with open(file, 'r', encoding="UTF-8") as f: content = f.read() else: content = None diff --git a/saltlint/formatters/default.py b/saltlint/formatters/default.py index 4b5ad50..9909c7a 100644 --- a/saltlint/formatters/default.py +++ b/saltlint/formatters/default.py @@ -10,17 +10,17 @@ class Formatter(BaseFormatter): def format(self, problem): - formatstr = u"{0} {1}\n{2}:{3}\n{4}\n" + formatstr = "{0} {1}\n{2}:{3}\n{4}\n" color = self.get_colors(self.colored) return formatstr.format( - u'{0}[{1}]{2}'.format(color['RED'], problem.rule.id, - color['ENDC']), - u'{0}{1}{2}'.format(color['LIGHT_RED'], problem.message, - color['ENDC']), - u'{0}{1}{2}'.format(color['BLUE'], problem.filename, - color['ENDC']), - u'{0}{1}{2}'.format(color['CYAN'], str(problem.linenumber), - color['ENDC']), - u'{0}{1}{2}'.format(color['MAGENTA'], problem.line, color['ENDC']) + '{0}[{1}]{2}'.format(color['RED'], problem.rule.id, + color['ENDC']), + '{0}{1}{2}'.format(color['LIGHT_RED'], problem.message, + color['ENDC']), + '{0}{1}{2}'.format(color['BLUE'], problem.filename, + color['ENDC']), + '{0}{1}{2}'.format(color['CYAN'], str(problem.linenumber), + color['ENDC']), + '{0}{1}{2}'.format(color['MAGENTA'], problem.line, color['ENDC']) ) diff --git a/saltlint/formatters/severity.py b/saltlint/formatters/severity.py index 904521a..e879cb6 100644 --- a/saltlint/formatters/severity.py +++ b/saltlint/formatters/severity.py @@ -9,19 +9,19 @@ class SeverityFormatter(BaseFormatter): def format(self, problem): - formatstr = u"{0} {sev} {1}\n{2}:{3}\n{4}\n" + formatstr = "{0} {sev} {1}\n{2}:{3}\n{4}\n" color = self.get_colors(self.colored) return formatstr.format( - u'{0}[{1}]{2}'.format(color['RED'], problem.rule.id, - color['ENDC']), - u'{0}{1}{2}'.format(color['LIGHT_RED'], problem.message, - color['ENDC']), - u'{0}{1}{2}'.format(color['BLUE'], problem.filename, - color['ENDC']), - u'{0}{1}{2}'.format(color['CYAN'], str(problem.linenumber), - color['ENDC']), - u'{0}{1}{2}'.format(color['MAGENTA'], problem.line, color['ENDC']), - sev=u'{0}[{1}]{2}'.format(color['RED'], problem.rule.severity, - color['ENDC']) + '{0}[{1}]{2}'.format(color['RED'], problem.rule.id, + color['ENDC']), + '{0}{1}{2}'.format(color['LIGHT_RED'], problem.message, + color['ENDC']), + '{0}{1}{2}'.format(color['BLUE'], problem.filename, + color['ENDC']), + '{0}{1}{2}'.format(color['CYAN'], str(problem.linenumber), + color['ENDC']), + '{0}{1}{2}'.format(color['MAGENTA'], problem.line, color['ENDC']), + sev='{0}[{1}]{2}'.format(color['RED'], problem.rule.severity, + color['ENDC']) ) diff --git a/saltlint/linter/match.py b/saltlint/linter/match.py index f3aa709..aad456a 100644 --- a/saltlint/linter/match.py +++ b/saltlint/linter/match.py @@ -13,6 +13,6 @@ def __init__(self, linenumber, line, filename, rule, message=None): self.message = message or rule.shortdesc def __repr__(self): - formatstr = u"[{0}] ({1}) matched {2}:{3} {4}" + formatstr = "[{0}] ({1}) matched {2}:{3} {4}" return formatstr.format(self.rule.id, self.message, self.filename, self.linenumber, self.line) diff --git a/saltlint/rules/NoIrregularSpacesRule.py b/saltlint/rules/NoIrregularSpacesRule.py index 53a371f..9f12392 100644 --- a/saltlint/rules/NoIrregularSpacesRule.py +++ b/saltlint/rules/NoIrregularSpacesRule.py @@ -13,30 +13,30 @@ class NoIrregularSpacesRule(Rule): version_added = 'v0.1.0' irregular_spaces = [ - u"\u000B", # Line Tabulation (\v) - - u"\u000C", # Form Feed (\f) - - u"\u00A0", # No-Break Space - - u"\u0085", # Next Line - u"\u1680", # Ogham Space Mark - u"\u180E", # Mongolian Vowel Separator - - u"\uFEFF", # Zero Width No-Break Space - - u"\u2000", # En Quad - u"\u2001", # Em Quad - u"\u2002", # En Space - - u"\u2003", # Em Space - - u"\u2004", # Tree-Per-Em - u"\u2005", # Four-Per-Em - u"\u2006", # Six-Per-Em - u"\u2007", # Figure Space - u"\u2008", # Punctuation Space - - u"\u2009", # Thin Space - u"\u200A", # Hair Space - u"\u200B", # Zero Width Space - - u"\u2028", # Line Separator - u"\u2029", # Paragraph Separator - u"\u202F", # Narrow No-Break Space - u"\u205F", # Medium Mathematical Space - u"\u3000", # Ideographic Space + "\u000B", # Line Tabulation (\v) - + "\u000C", # Form Feed (\f) - + "\u00A0", # No-Break Space - + "\u0085", # Next Line + "\u1680", # Ogham Space Mark + "\u180E", # Mongolian Vowel Separator - + "\uFEFF", # Zero Width No-Break Space - + "\u2000", # En Quad + "\u2001", # Em Quad + "\u2002", # En Space - + "\u2003", # Em Space - + "\u2004", # Tree-Per-Em + "\u2005", # Four-Per-Em + "\u2006", # Six-Per-Em + "\u2007", # Figure Space + "\u2008", # Punctuation Space - + "\u2009", # Thin Space + "\u200A", # Hair Space + "\u200B", # Zero Width Space - + "\u2028", # Line Separator + "\u2029", # Paragraph Separator + "\u202F", # Narrow No-Break Space + "\u205F", # Medium Mathematical Space + "\u3000", # Ideographic Space ] def match(self, file, line):