[PATCH 11/10] scripts/xls_to_doc.py: make pylint happy

Kamil Konieczny kamil.konieczny at linux.intel.com
Fri Mar 15 09:15:50 UTC 2024


Hi Mauro,
On 2024-03-15 at 09:50:18 +0100, Mauro Carvalho Chehab wrote:
> From: Mauro Carvalho Chehab <mchehab at kernel.org>
> 
> Pylint is too picky. Still, it is useful to run it, as sometimes
> it could point to real issues.
> 
> So, let's make it happy by:
> - disabling R0902, which is one of those "too many" warnings
>   (IMO, it doesn't make sense to limit the number of times some
>   thing can be used inside a code;
> 
> - disabling another warning about not using .items(). On that
>   particular case, IMO it will make the code less clearer for
>   reviewers and future maintainership, e. g.:
> 
> 	test_nr = self.tests[testname].get("Test")
> 
>   and similar occurrences for self.tests[testname] is a lot clearer
>   than:
> 
> 	for testname, value in self.tests.items():
> 		...
> 		test_nr = value.get("Test")
> 		...
> 		value["subtests"][subtest][k] = val
> 
> 	(and other similar occurrences)
> 
>   ok, a better name than "value" might help, but still the
>   obvious choice would be "test", "test_testname" and such,
>   which just makes the code more obfuscated.
> 
>   So, ignore the warning for good.
> 
> - remove a blank line before a docstring comment;
> 
> - remove a currently unused argument from update_files;
> 
> - fix indent on a single line.
> 
> No functional changes.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>

Acked-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>


> ---
>  scripts/xls_to_doc.py | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/scripts/xls_to_doc.py b/scripts/xls_to_doc.py
> index 6492c5d8337a..50ae56477647 100755
> --- a/scripts/xls_to_doc.py
> +++ b/scripts/xls_to_doc.py
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env python3
> -# pylint: disable=C0301,R0912,R0913,R0914,R0915,R1702
> +# pylint: disable=C0301,R0902,R0912,R0913,R0914,R0915,R1702
>  # SPDX-License-Identifier: (GPL-2.0 OR MIT)
>  
>  ## Copyright (C) 2023    Intel Corporation                 ##
> @@ -97,7 +97,6 @@ class FillTests(TestList):
>          dic[field] = value
>  
>      def process_spreadsheet_sheet(self, sheet):
> -
>          """
>          Convert a single sheet into a dictionary.
>  
> @@ -299,7 +298,7 @@ class FillTests(TestList):
>  
>          print("Handling common information on test from subtests")
>  
> -        for testname in self.tests:
> +        for testname in self.tests:                  # pylint: disable=C0206
>              # Get common properties
>              common = {}
>              test_nr = self.tests[testname].get("Test")
> @@ -363,7 +362,7 @@ class FillTests(TestList):
>              for k, val in common.items():
>                  self.doc[test_nr][k] = val
>  
> -    def update_test_file(self, testname, args):
> +    def update_test_file(self, testname):
>          """
>          Update a C source file using the contents of self.tests as
>          the source of data to be filled at the igt_doc documentation
> @@ -419,7 +418,7 @@ class FillTests(TestList):
>  
>                  for field in sorted(fields):
>                      if field not in self.update_fields:
> -                            continue
> +                        continue
>  
>                      value = subtest_content.get(field, "")
>                      doc_value = doc_content.get(field, "")
> @@ -472,7 +471,7 @@ class FillTests(TestList):
>          except EnvironmentError:
>              print(f'Failed to write to {sourcename}')
>  
> -    def update_test_files(self, args):
> +    def update_test_files(self):
>          """
>          Populate all test files with the documentation from self.tests.
>          """
> @@ -481,7 +480,7 @@ class FillTests(TestList):
>              print("Update source files")
>  
>          for testname in self.tests:
> -            self.update_test_file(testname, args)
> +            self.update_test_file(testname)
>  
>  ######
>  # Main
> @@ -525,7 +524,7 @@ def main():
>          with open("doc.json", "w", encoding='utf8') as write_file:
>              json.dump(fill_test.doc, write_file, indent=4)
>  
> -    fill_test.update_test_files(parse_args)
> +    fill_test.update_test_files()
>  
>  
>  if __name__ == '__main__':
> -- 
> 2.43.2
> 


More information about the igt-dev mailing list