Skip to contentSkip to conversation

utils/check-package: cleanup line reading

PATCH Superseded James Knight 3 participants 7 messages Apr 29, 2023 – Sep 3, 2023 1 message not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/4 utils/check-package: cleanup line reading

Cleanup the implementation for reading lines by having files processed in context managers and utilizing the iterable file object for line reading (instead of needing to call readlines()).

---
 utils/check-package | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
utils/check-package +12 -10
index 83b9750f5a9c181dc96dcba508682776a600aac5..db3a00b524bc2c2aa663d3621c94fb11a6db7cb3 100755
@@ -229,16 +229,18 @@ def check_file_using_lib(fname):
         nwarnings += warn
 
     lastline = ""
-    for lineno, text in enumerate(open(fname, "r", errors="surrogateescape").readlines()):
-        nlines += 1
-        for name, cf in objects:
-            if cf.disable.search(lastline):
-                continue
-            warn, fail = print_warnings(cf.check_line(lineno + 1, text), name in xfail)
-            if fail > 0:
-                failed.add(name)
-            nwarnings += warn
-        lastline = text
+    with open(fname, "r", errors="surrogateescape") as f:
+        for lineno, text in enumerate(f):
+            nlines += 1
+            for name, cf in objects:
+                if cf.disable.search(lastline):
+                    continue
+                line_sts = cf.check_line(fstate, lineno + 1, text)
+                warn, fail = print_warnings(line_sts, name in xfail)
+                if fail > 0:
+                    failed.add(name)
+                nwarnings += warn
+            lastline = text
 
     for name, cf in objects:
         warn, fail = print_warnings(cf.after(), name in xfail)
Signature · 6 lines
2.40.1.windows.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hello James,

Quoted 24 lines · On Sat, 29 Apr 2023 14:12:02 -0400 James Knight <[email protected]> wrote:

Cleanup the implementation for reading lines by having files processed in context managers and utilizing the iterable file object for line reading (instead of needing to call readlines()).

---
 utils/check-package | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
utils/check-package +0 -7
index 83b9750f5a9c181dc96dcba508682776a600aac5..db3a00b524bc2c2aa663d3621c94fb11a6db7cb3 100755
@@ -229,16 +229,18 @@ def check_file_using_lib(fname):
         nwarnings += warn
 
     lastline = ""
-    for lineno, text in enumerate(open(fname, "r", errors="surrogateescape").readlines()):
-        nlines += 1
-        for name, cf in objects:
-            if cf.disable.search(lastline):
-                continue
-            warn, fail = print_warnings(cf.check_line(lineno + 1, text), name in xfail)
-            if fail > 0:

utils/check-package def check_file_using_lib(fname): · line 238

Quoted 10 lines
utils/check-package +7 -3
-                failed.add(name)
-            nwarnings += warn
-        lastline = text
+    with open(fname, "r", errors="surrogateescape") as f:
+        for lineno, text in enumerate(f):
+            nlines += 1
+            for name, cf in objects:
+                if cf.disable.search(lastline):
+                    continue
+                line_sts = cf.check_line(fstate, lineno + 1, text)

This variable "fstate" doesn't exist as of PATCH 1/4. I wanted to apply only this patch for now, as I'm not sure about PATCH 2/4 to PATCH 4/4, but PATCH 1/4 on its own doesn't work. Could you have a look?

Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH 2/4 utils/check-package: support a file-state instance for library types

In reply to a message not in the archive

The following adds support to the checkpackage library to have a file-specific state instance that can be changed across multiple check_line calls. This allows a given library type to provide hints across different lines (if needed).

This is in preparation for a future commit to provide support for linter suppression that is configured in the files being processed.

---
 utils/check-package                 |  8 ++++++++
 utils/checkpackagelib/base.py       |  2 +-
 utils/checkpackagelib/lib.py        | 10 +++++-----
 utils/checkpackagelib/lib_config.py | 10 +++++-----
 utils/checkpackagelib/lib_hash.py   |  6 +++---
 utils/checkpackagelib/lib_mk.py     | 22 +++++++++++-----------
 utils/checkpackagelib/lib_patch.py  |  6 +++---
 utils/checkpackagelib/lib_sysv.py   |  4 ++--
 utils/checkpackagelib/test_util.py  |  4 ++--
 9 files changed, 40 insertions(+), 32 deletions(-)
utils/check-package +8 -0
index db3a00b524bc2c2aa663d3621c94fb11a6db7cb3..890420fe6992d49ad7d50f311007689e35ab7681 100755
@@ -220,6 +220,12 @@ def check_file_using_lib(fname):
         print("{}: would run: {}".format(fname, functions_to_run))
         return nwarnings, nlines
 
+    # Check if there is a state tracker we can create for this library type,
+    # and then forward to each `check_line` invoked
+    fstate = None
+    if hasattr(lib, 'State') and inspect.isclass(lib.State):
+        fstate = lib.State()
+
     objects = [[c[0], c[1](fname, flags.manual_url)] for c in internal_functions]
 
     for name, cf in objects:
@@ -231,6 +237,8 @@ def check_file_using_lib(fname):
     lastline = ""
     with open(fname, "r", errors="surrogateescape") as f:
         for lineno, text in enumerate(f):
+            if fstate:
+                fstate.process(text)
             nlines += 1
             for name, cf in objects:
                 if cf.disable.search(lastline):
utils/checkpackagelib/base.py +1 -1
index f666e4110b1abbc87ad6a00ebcf16c03a7be8885..ac87685eef13080f4b14c656cbae98d2f22aac12 100644
@@ -11,7 +11,7 @@ class _CheckFunction(object):
     def before(self):
         pass
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         pass
 
     def after(self):
utils/checkpackagelib/lib.py +5 -5
index 457b3c317198bd5a798d164b6c629b621539f8cc..a121b5b1c072fce46c7da486db70c1fbd80461e2 100644
@@ -7,7 +7,7 @@ class ConsecutiveEmptyLines(_CheckFunction):
     def before(self):
         self.lastline = "non empty"
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if text.strip() == "" == self.lastline.strip():
             return ["{}:{}: consecutive empty lines"
                     .format(self.filename, lineno)]
@@ -19,7 +19,7 @@ class EmptyLastLine(_CheckFunction):
         self.lastlineno = 0
         self.lastline = "non empty"
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         self.lastlineno = lineno
         self.lastline = text
 
@@ -34,7 +34,7 @@ class NewlineAtEof(_CheckFunction):
         self.lastlineno = 0
         self.lastline = "\n"
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         self.lastlineno = lineno
         self.lastline = text
 
@@ -46,7 +46,7 @@ class NewlineAtEof(_CheckFunction):
 
 
 class TrailingSpace(_CheckFunction):
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         line = text.rstrip("\r\n")
         if line != line.rstrip():
             return ["{}:{}: line contains trailing whitespace"
@@ -61,7 +61,7 @@ class Utf8Characters(_CheckFunction):
         except TypeError:
             return False
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if not self.is_ascii(text):
             return ["{}:{}: line contains UTF-8 characters"
                     .format(self.filename, lineno),
utils/checkpackagelib/lib_config.py +5 -5
index f26ca0d89807cf827c81c51fd7cfa694ad4514ad..6e65eed66b490c6d477de67ff7589e9f05da4e28 100644
@@ -37,7 +37,7 @@ class AttributesOrder(_CheckFunction):
     def before(self):
         self.state = 0
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if _empty_or_comment(text) or _part_of_help_text(text):
             return
 
@@ -87,7 +87,7 @@ class CommentsMenusPackagesOrder(_CheckFunction):
         self.level = self.get_level()
         self.initialize_package_level_elements(text)
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         # We only want to force sorting for the top-level menus
         if self.filename not in ["fs/Config.in",
                                  "package/Config.in",
@@ -159,7 +159,7 @@ class HelpText(_CheckFunction):
     def before(self):
         self.help_text = False
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if _empty_or_comment(text):
             return
 
@@ -194,7 +194,7 @@ class Indent(_CheckFunction):
     def before(self):
         self.backslash = False
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if _empty_or_comment(text) or _part_of_help_text(text):
             self.backslash = False
             return
@@ -244,7 +244,7 @@ class RedefinedConfig(_CheckFunction):
         self.configs = {}
         self.conditional = []
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if _empty_or_comment(text) or _part_of_help_text(text):
             return
 
utils/checkpackagelib/lib_hash.py +3 -3
index 5968c809bfa2f925ecf900b9bd95637d0c81c7b0..c1ba281ee2067724cb40fab739ef357981ffaab4 100644
@@ -18,7 +18,7 @@ def _empty_line_or_comment(text):
 
 
 class HashNumberOfFields(_CheckFunction):
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if _empty_line_or_comment(text):
             return
 
@@ -33,7 +33,7 @@ class HashType(_CheckFunction):
     len_of_hash = {"md5": 32, "sha1": 40, "sha224": 56, "sha256": 64,
                    "sha384": 96, "sha512": 128}
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if _empty_line_or_comment(text):
             return
 
@@ -55,7 +55,7 @@ class HashType(_CheckFunction):
 
 
 class HashSpaces(_CheckFunction):
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if _empty_line_or_comment(text):
             return
 
utils/checkpackagelib/lib_mk.py +11 -11
index d340882971f165bf1e2acd288c4b8552cb2dbc3b..4114e89ee04ea407d18a5e9f59d88d885b4d7008 100644
@@ -24,7 +24,7 @@ end_conditional = ["endif"]
 class DoNotInstallToHostdirUsr(_CheckFunction):
     INSTALL_TO_HOSTDIR_USR = re.compile(r"^[^#].*\$\(HOST_DIR\)/usr")
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.INSTALL_TO_HOSTDIR_USR.match(text.rstrip()):
             return ["{}:{}: install files to $(HOST_DIR)/ instead of $(HOST_DIR)/usr/"
                     .format(self.filename, lineno),
@@ -34,7 +34,7 @@ class DoNotInstallToHostdirUsr(_CheckFunction):
 class Ifdef(_CheckFunction):
     IFDEF = re.compile(r"^\s*(else\s+|)(ifdef|ifndef)\s")
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         m = self.IFDEF.search(text)
         if m is None:
             return
@@ -62,7 +62,7 @@ class Indent(_CheckFunction):
         self.backslash = False
         self.makefile_target = False
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.START_DEFINE.search(text):
             self.define = True
             return
@@ -126,7 +126,7 @@ class OverriddenVariable(_CheckFunction):
         self.unconditionally_set = []
         self.conditionally_set = []
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.START_CONDITIONAL.search(text):
             self.conditional += 1
             return
@@ -178,7 +178,7 @@ class PackageHeader(_CheckFunction):
     def before(self):
         self.skip = False
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.skip or lineno > 6:
             return
 
@@ -214,7 +214,7 @@ class RemoveDefaultPackageSourceVariable(_CheckFunction):
             r"^{}_SOURCE\s*=\s*{}-\$\({}_VERSION\)\.tar\.gz"
             .format(package_upper, package, package_upper))
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.FIND_SOURCE.search(text):
 
             if self.package in self.packages_that_may_contain_default_source:
@@ -229,7 +229,7 @@ class RemoveDefaultPackageSourceVariable(_CheckFunction):
 class SpaceBeforeBackslash(_CheckFunction):
     TAB_OR_MULTIPLE_SPACES_BEFORE_BACKSLASH = re.compile(r"^.*(  |\t ?)\\$")
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.TAB_OR_MULTIPLE_SPACES_BEFORE_BACKSLASH.match(text.rstrip()):
             return ["{}:{}: use only one space before backslash"
                     .format(self.filename, lineno),
@@ -242,7 +242,7 @@ class TrailingBackslash(_CheckFunction):
     def before(self):
         self.backslash = False
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         last_line_ends_in_backslash = self.backslash
 
         # calculate for next line
@@ -294,7 +294,7 @@ class TypoInPackageVariable(_CheckFunction):
             r"^{}_PROVIDES\s*(\+|)=\s*(.*)".format(package))
         self.virtual = []
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         m = self.VARIABLE.search(text)
         if m is None:
             return
@@ -333,7 +333,7 @@ class UselessFlag(_CheckFunction):
     def before(self):
         self.conditional = 0
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.START_CONDITIONAL.search(text):
             self.conditional += 1
             return
@@ -361,7 +361,7 @@ class UselessFlag(_CheckFunction):
 class VariableWithBraces(_CheckFunction):
     VARIABLE_WITH_BRACES = re.compile(r"^[^#].*[^$]\${\w+}")
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.VARIABLE_WITH_BRACES.match(text.rstrip()):
             return ["{}:{}: use $() to delimit variables, not ${{}}"
                     .format(self.filename, lineno),
utils/checkpackagelib/lib_patch.py +3 -3
index 1909d3acd063800345b9e040c05b74bb3a05b96c..985f925d2ca9201ca053d4fb192cd5c7c4dba486 100644
@@ -29,7 +29,7 @@ class NumberedSubject(_CheckFunction):
         self.lineno = 0
         self.text = None
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if text.startswith("diff --git"):
             self.git_patch = True
             return
@@ -50,7 +50,7 @@ class Sob(_CheckFunction):
     def before(self):
         self.found = False
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.found:
             return
         if self.SOB_ENTRY.search(text):
@@ -68,7 +68,7 @@ class Upstream(_CheckFunction):
     def before(self):
         self.found = False
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.found:
             return
         if self.UPSTREAM_ENTRY.search(text):
utils/checkpackagelib/lib_sysv.py +2 -2
index dc4afd71b80577ba80c0ebb60a626e793fd94637..8df4f7d507bb8aca32228d63b05b02470d80427b 100644
@@ -13,7 +13,7 @@ from checkpackagelib.tool import Shellcheck            # noqa: F401
 class Indent(_CheckFunction):
     INDENTED_WITH_SPACES = re.compile(r"^[\t]* ")
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         if self.INDENTED_WITH_SPACES.search(text.rstrip()):
             return ["{}:{}: should be indented with tabs ({}#adding-packages-start-script)"
                     .format(self.filename, lineno, self.url_to_manual),
@@ -36,7 +36,7 @@ class Variables(_CheckFunction):
     def before(self):
         self.name = None
 
-    def check_line(self, lineno, text):
+    def check_line(self, state, lineno, text):
         name_found = self.DAEMON_VAR.search(text.rstrip())
         if name_found:
             if self.name:
utils/checkpackagelib/test_util.py +2 -2
index 23f2995e2721ccb2c64266e8aeb095f308e308bb..84117b8dbfa6c003263ccd4fb095d27b8a3ee976 100644
@@ -1,8 +1,8 @@
-def check_file(check_function, filename, string):
+def check_file(check_function, filename, string, state=None):
     obj = check_function(filename, 'url')
     result = []
     result.append(obj.before())
     for i, line in enumerate(string.splitlines(True)):
-        result.append(obj.check_line(i + 1, line))
+        result.append(obj.check_line(state, i + 1, line))
     result.append(obj.after())
     return [r for r in result if r is not None]
Signature · 6 lines
2.40.1.windows.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Re: [Buildroot] [PATCH 2/4] utils/check-package: support a file-state instance for library types

Hello,

Sorry the long delay.

Quoted 10 lines · James Knight

from: James Knight <[email protected]>
date: Sat, Apr 29 02:12 PM -04:00 2023
to: [email protected]
cc: James Knight <[email protected]>, Ricardo Martincoski <[email protected]>
subject: [Buildroot] [PATCH 2/4] utils/check-package: support a file-state instance for library types

The following adds support to the checkpackage library to have a file-specific state instance that can be changed across multiple check_line calls. This allows a given library type to provide hints across different lines (if needed).

This is a great idea.

Quoted 35 lines

This is in preparation for a future commit to provide support for linter suppression that is configured in the files being processed.

---
 utils/check-package                 |  8 ++++++++
 utils/checkpackagelib/base.py       |  2 +-
 utils/checkpackagelib/lib.py        | 10 +++++-----
 utils/checkpackagelib/lib_config.py | 10 +++++-----
 utils/checkpackagelib/lib_hash.py   |  6 +++---
 utils/checkpackagelib/lib_mk.py     | 22 +++++++++++-----------
 utils/checkpackagelib/lib_patch.py  |  6 +++---
 utils/checkpackagelib/lib_sysv.py   |  4 ++--
 utils/checkpackagelib/test_util.py  |  4 ++--
 9 files changed, 40 insertions(+), 32 deletions(-)
utils/check-package +6 -0
index db3a00b524bc2c2aa663d3621c94fb11a6db7cb3..890420fe6992d49ad7d50f311007689e35ab7681 100755
@@ -220,6 +220,12 @@ def check_file_using_lib(fname):
         print("{}: would run: {}".format(fname, functions_to_run))
         return nwarnings, nlines
 
+    # Check if there is a state tracker we can create for this library type,
+    # and then forward to each `check_line` invoked
+    fstate = None
+    if hasattr(lib, 'State') and inspect.isclass(lib.State):
+        fstate = lib.State()
+
     objects = [[c[0], c[1](fname, flags.manual_url)] for c in internal_functions]
 
     for name, cf in objects:

utils/check-package def check_file_using_lib(fname): · line 244

Quoted 8 lines
utils/check-package +2 -0
@@ -231,6 +237,8 @@ def check_file_using_lib(fname):
     lastline = ""
     with open(fname, "r", errors="surrogateescape") as f:
         for lineno, text in enumerate(f):
+            if fstate:
+                fstate.process(text)
             nlines += 1
             for name, cf in objects:
                 if cf.disable.search(lastline):

This line of code (that is already there) made me wonder if we can factor-out this code to the base class and add the new implementation there.
The advantages of this alternative are:
- avoid adding code to the main check-package script that currently is not covered by unit tests
- avoid the need to change all users of the base class

I will send shortly a patch with this factor-out.

Regards,
Ricardo

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw

PATCH 3/4 utils/check-package: support ignore-indent flag for configurations

In reply to a message not in the archive

This commit provides the ability for configuration scripts to hint at ignoring linter checks for expected indentations. By adding the line to a configuration file:

# noqa: ignore-indent

Calls to check-package will ignore any custom indentation the configuration script may have. This can be useful for "container" configurations which include packages or other sub-packages, without having to add explicit bypasses into the checkpackagelib library.

This avoids maintaining special file lists inside lib_config.py, as well as allows br2-external tree to easily utilize the linter script without having to worry about indentation on container-like configuration definitions.

---
 utils/checkpackagelib/lib_config.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
utils/checkpackagelib/lib_config.py +18 -0
index 6e65eed66b490c6d477de67ff7589e9f05da4e28..52539d97ab60664d0466b42e28b3aac5577db5fb 100644
@@ -224,6 +224,8 @@ class Indent(_CheckFunction):
                         text]
         elif entry in entries_that_should_not_be_indented:
             if not text.startswith(entry):
+                if state and 'ignore-indent' in state.noqa_flags:
+                    return
                 # four Config.in files have a special but legitimate indentation rule
                 if self.filename in ["package/Config.in",
                                      "package/Config.in.host",
@@ -271,3 +273,19 @@ class RedefinedConfig(_CheckFunction):
                     .format(self.filename, lineno, config, previous_line),
                     text]
         self.configs[key] = lineno
+
+
+class State:
+    def __init__(self):
+        self.noqa_flags = set()
+
+    def process(self, line):
+        if not _empty_or_comment(line):
+            return
+
+        # if `noqa:` token is detected, consider trailing options as noqa
+        # tokens assigned on the file
+        if "noqa:" in line:
+            flags = line.partition("noqa:")[2].lower().split()
+            if flags:
+                self.noqa_flags.update(flags)
Signature · 6 lines
2.40.1.windows.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

Re: [Buildroot] [PATCH 3/4] utils/check-package: support ignore-indent flag for configurations

Hello,

Sorry the long delay.

Quoted 11 lines · James Knight

from: James Knight <[email protected]>
date: Sat, Apr 29 02:12 PM -04:00 2023
to: [email protected]
cc: James Knight <[email protected]>, Ricardo Martincoski <[email protected]>
subject: [Buildroot] [PATCH 3/4] utils/check-package: support ignore-indent flag for configurations

This commit provides the ability for configuration scripts to hint at ignoring linter checks for expected indentations. By adding the line to a configuration file:

# noqa: ignore-indent

There is already support for comments in the form

    # check-package Indent
to not run a CheckFunction named Indent for the next source code line

It seems to me that using 'check-package' in the special comment does make sense because someone reading the source file, for instance a Config.in file, can immediately know it is something related to the check-package script, while a 'noqa' would need to be documented in the manual.
Also, using 'check-package' in the comment would keep consistency with code that already exists.
Finally, it seems to me more future-proof to keep the naming space of all flags/options inside each CheckFunction, so I would suggest a comment in the form:

    # check-package Indent_ignore-menu-indent-below

that sets the flag named 'ignore-menu-indent-below' for the CheckFunction named 'Indent' in the library that parses the type of file that has the special comment, in the case of Config.in, lib_config.py.

Regards,
Ricardo

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#7 lore raw

PATCH 4/4 utils/check-package: utilize ignore-indent flag for special configs

In reply to a message not in the archive

Applies the ignore-indent flag to multiple configuration files, allowing these special files to removed from an internal list managed inside checkpackagelib/lib_config.py.

---
 package/Config.in                   | 2 ++
 package/Config.in.host              | 2 ++
 package/kodi/Config.in              | 2 ++
 package/x11r7/Config.in             | 2 ++
 utils/checkpackagelib/lib_config.py | 6 ------
 5 files changed, 8 insertions(+), 6 deletions(-)
package/Config.in +2 -0
index eaac32a01af363936edc8a0a8dd2450c458a38ae..9b7899c8da6e98353fba8a360f56df8a4a191b95 100644
@@ -1,3 +1,5 @@
+# noqa: ignore-indent
+
 menu "Target packages"
 
 	source "package/busybox/Config.in"
package/Config.in.host +2 -0
index dcadbfdfc1b0f2799c37dcc70b9e6c1203c4cccd..ab76d2aebc05abd18448336777f8d1b5b439edb8 100644
@@ -1,3 +1,5 @@
+# noqa: ignore-indent
+
 menu "Host utilities"
 
 	source "package/abootimg/Config.in.host"
package/kodi/Config.in +2 -0
index 7bd8bc2943d4719b1af4f634d729ae0ae5c50e92..8befa9b6cdcebcf71c06c9e153fabfc776cdb2cf 100644
@@ -1,3 +1,5 @@
+# noqa: ignore-indent
+
 config BR2_PACKAGE_KODI_ARCH_SUPPORTS
 	bool
 	default y if BR2_PACKAGE_FFMPEG_ARCH_SUPPORTS
package/x11r7/Config.in +2 -0
index 4de8922e0d505431181d1df4473c54660311552e..80f25fa94b106f41563727c5fe2de18f110ededc 100644
@@ -1,3 +1,5 @@
+# noqa: ignore-indent
+
 menuconfig BR2_PACKAGE_XORG7
 	bool "X.org X Window System"
 	depends on BR2_USE_WCHAR
utils/checkpackagelib/lib_config.py +0 -6
index 52539d97ab60664d0466b42e28b3aac5577db5fb..7aa4c535a6814fd479b3cfdc44c6cb10e53aa70f 100644
@@ -226,12 +226,6 @@ class Indent(_CheckFunction):
             if not text.startswith(entry):
                 if state and 'ignore-indent' in state.noqa_flags:
                     return
-                # four Config.in files have a special but legitimate indentation rule
-                if self.filename in ["package/Config.in",
-                                     "package/Config.in.host",
-                                     "package/kodi/Config.in",
-                                     "package/x11r7/Config.in"]:
-                    return
                 return ["{}:{}: should not be indented"
                         .format(self.filename, lineno),
                         text]
Signature · 6 lines
2.40.1.windows.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot