From 868350681a1b077d3bbb9115e36dcf100d9adef7 Mon Sep 17 00:00:00 2001
From: Dimitri Papadopoulos Orfanos
<3234522+DimitriPapadopoulos@users.noreply.github.com>
Date: Sat, 6 Aug 2022 15:14:57 +0200
Subject: [PATCH 1/3] License: Update to latest version of GPLv3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
http:// → https://
---
LICENSE | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/LICENSE b/LICENSE
index 94a9ed0..f288702 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
-.
+.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
-.
+.
From 6b6fdba3bf831a075c36fa6d56262b422bf96355 Mon Sep 17 00:00:00 2001
From: Dimitri Papadopoulos
<3234522+DimitriPapadopoulos@users.noreply.github.com>
Date: Fri, 5 Aug 2022 21:56:21 +0200
Subject: [PATCH 2/3] linter: pre-compile disable/enable rules regexes
Not only this should improve performance, but I find the code more
readable.
---
yamllint/linter.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/yamllint/linter.py b/yamllint/linter.py
index 3984970..58dbba4 100644
--- a/yamllint/linter.py
+++ b/yamllint/linter.py
@@ -29,6 +29,9 @@ PROBLEM_LEVELS = {
'error': 2,
}
+DISABLE_RULE_PATTERN = re.compile(r'^# yamllint disable( rule:\S+)*\s*$')
+ENABLE_RULE_PATTERN = re.compile(r'^# yamllint enable( rule:\S+)*\s*$')
+
class LintProblem(object):
"""Represents a linting problem found by yamllint."""
@@ -82,7 +85,7 @@ def get_cosmetic_problems(buffer, conf, filepath):
def process_comment(self, comment):
comment = str(comment)
- if re.match(r'^# yamllint disable( rule:\S+)*\s*$', comment):
+ if DISABLE_RULE_PATTERN.match(comment):
items = comment[18:].rstrip().split(' ')
rules = [item[5:] for item in items][1:]
if len(rules) == 0:
@@ -92,7 +95,7 @@ def get_cosmetic_problems(buffer, conf, filepath):
if id in self.all_rules:
self.rules.add(id)
- elif re.match(r'^# yamllint enable( rule:\S+)*\s*$', comment):
+ elif ENABLE_RULE_PATTERN.match(comment):
items = comment[17:].rstrip().split(' ')
rules = [item[5:] for item in items][1:]
if len(rules) == 0:
From e319a173442c9946537db712e749258b642833cc Mon Sep 17 00:00:00 2001
From: Dimitri Papadopoulos
<3234522+DimitriPapadopoulos@users.noreply.github.com>
Date: Fri, 5 Aug 2022 22:02:07 +0200
Subject: [PATCH 3/3] octal values: simpler test for match objects
From the Python 3 documentation:
Match objects always have a boolean value of True.
Since match() and search() return None when there is no match,
you can test whether there was a match with a simple if statement:
match = re.search(pattern, string)
if match:
process(match)
---
yamllint/rules/octal_values.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/yamllint/rules/octal_values.py b/yamllint/rules/octal_values.py
index d531a89..7796e50 100644
--- a/yamllint/rules/octal_values.py
+++ b/yamllint/rules/octal_values.py
@@ -96,7 +96,7 @@ def check(conf, token, prev, next, nextnext, context):
if not token.style:
val = token.value
if (val.isdigit() and len(val) > 1 and val[0] == '0' and
- IS_OCTAL_NUMBER_PATTERN.match(val[1:]) is not None):
+ IS_OCTAL_NUMBER_PATTERN.match(val[1:])):
yield LintProblem(
token.start_mark.line + 1, token.end_mark.column + 1,
'forbidden implicit octal value "%s"' %
@@ -107,7 +107,7 @@ def check(conf, token, prev, next, nextnext, context):
if not token.style:
val = token.value
if (len(val) > 2 and val[:2] == '0o' and
- IS_OCTAL_NUMBER_PATTERN.match(val[2:]) is not None):
+ IS_OCTAL_NUMBER_PATTERN.match(val[2:])):
yield LintProblem(
token.start_mark.line + 1, token.end_mark.column + 1,
'forbidden explicit octal value "%s"' %