From e71916d0ff6fff3949507e625559b39f00f8f7ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Thu, 25 Jan 2024 07:25:47 +0100 Subject: [PATCH] Fix exclusion in Flake8 configuration (#16087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #16071 Summary of the issue: When linting we exclude certain directories where the code is auto generated. These exclusions are not working (this probably regressed with the Flake8 update, though I haven't checked). Description of user facing changes When linting exclusions in Flake8 configuration are once again respected. Description of development approach Flake8 considers that paths in the exclusion list are provided relative to the config file location not to the CWD, our exclusions were modified to account for this After the file was modified I started getting errors due to usage of inline comments, apparently this was never supposed to work, as per this quote from the documentation: Following the recommended settings for Python’s configparser, Flake8 does not support inline comments for any of the keys. So while this is fine:... Therefore we no longer use inline comments in the config. --- tests/lint/flake8.ini | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/tests/lint/flake8.ini b/tests/lint/flake8.ini index d9e45e08644..40ac7ccdd46 100644 --- a/tests/lint/flake8.ini +++ b/tests/lint/flake8.ini @@ -27,26 +27,38 @@ max-line-length = 110 hang-closing = False ignore = - W191, # indentation contains tabs - W503, # line break before binary operator. We want W504(line break after binary operator) + # indentation contains tabs + W191, + # Line break before binary operator. + # We want W504 (line break after binary operator). + W503, +# inform flake8 about functions we consider built-in. +builtins = + # translation lookup + _, + # translation lookup + ngettext, + # translation lookup + pgettext, + # translation lookup + npgettext, -builtins = # inform flake8 about functions we consider built-in. - _, # translation lookup - ngettext, # translation lookup - pgettext, # translation lookup - npgettext, # translation lookup - -exclude = # don't bother looking in the following subdirectories / files. +# don't bother looking in the following subdirectories / files. +exclude = .git, __pycache__, .tox, build, output, - include/*, - miscDeps, - source/louis, - source/comInterfaces/*, # #10924: generated by third-party dependencies + # When excluding concrete paths relative to a directory, + # not matching multiple folders by name e.g. `__pycache__`, + # paths are relative to the configuration file. + ../../include/*, + ../../miscDeps, + ../../source/louis, + # #10924: generated by third-party dependencies + ../../source/comInterfaces/*, filename = *.py,