diff --git a/pyproject.toml b/pyproject.toml index 8e9f6b33862caf..6b51197ad66c2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ ignore = [ "E7", "PLC1901", "RUF005", + "RUF100", ] line-length = 172 target-version = "py37" @@ -34,6 +35,12 @@ target-version = "py37" [tool.ruff.mccabe] max-complexity = 100 +[tool.ruff.per-file-ignores] +"tools/checkimports.py" = ["W605"] +"tools/gyp/pylib/gyp/xcodeproj_file.py" = ["PLE0101"] +"tools/icu/shrink-icu-src.py" = ["W605"] +"tools/mkssldef.py" = ["W605"] + [tool.ruff.pylint] max-args = 12 max-branches = 110 diff --git a/tools/checkimports.py b/tools/checkimports.py index 629569c06abd3f..b94919e3cc47e4 100755 --- a/tools/checkimports.py +++ b/tools/checkimports.py @@ -8,7 +8,7 @@ import itertools def do_exist(file_name, lines, imported): - if not any(not re.match('using \\w+::{0};'.format(imported), line) and + if not any(not re.match('using \w+::{0};'.format(imported), line) and re.search('\\b{0}\\b'.format(imported), line) for line in lines): print('File "{0}" does not use "{1}"'.format(file_name, imported)) return False diff --git a/tools/gyp/gyp_main.py b/tools/gyp/gyp_main.py index 754ce5b3cdc0c1..f23dcdf882d1b0 100755 --- a/tools/gyp/gyp_main.py +++ b/tools/gyp/gyp_main.py @@ -39,7 +39,7 @@ def UnixifyPath(path): # else the 'gyp' library will not be found path = UnixifyPath(sys.argv[0]) sys.path.insert(0, os.path.join(os.path.dirname(path), "pylib")) -import gyp +import gyp # noqa: E402 if __name__ == "__main__": sys.exit(gyp.script_main()) diff --git a/tools/gyp/pylib/gyp/generator/make.py b/tools/gyp/pylib/gyp/generator/make.py index bf9be1b02b7556..e225326e1d09b6 100644 --- a/tools/gyp/pylib/gyp/generator/make.py +++ b/tools/gyp/pylib/gyp/generator/make.py @@ -216,7 +216,7 @@ def CalculateGeneratorInputInfo(params): quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -""" +""" # noqa: E501 LINK_COMMANDS_ANDROID = """\ quiet_cmd_alink = AR($(TOOLSET)) $@ @@ -286,7 +286,7 @@ def CalculateGeneratorInputInfo(params): quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -""" +""" # noqa: E501 LINK_COMMANDS_OS400 = """\ @@ -304,7 +304,7 @@ def CalculateGeneratorInputInfo(params): quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -""" +""" # noqa: E501 LINK_COMMANDS_OS390 = """\ @@ -474,7 +474,7 @@ def CalculateGeneratorInputInfo(params): cmd_symlink = ln -sf "$<" "$@" %(link_commands)s -""" +""" # noqa: E501 r""" # Define an escape_quotes function to escape single quotes. # This allows us to handle quotes properly as long as we always use @@ -573,7 +573,7 @@ def CalculateGeneratorInputInfo(params): .PHONY: FORCE_DO_CMD FORCE_DO_CMD: -""" +""" # noqa: E501 ) SHARED_HEADER_MAC_COMMANDS = """ @@ -604,7 +604,7 @@ def CalculateGeneratorInputInfo(params): quiet_cmd_infoplist = INFOPLIST $@ cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" -""" +""" # noqa: E501 def WriteRootHeaderSuffixRules(writer): diff --git a/tools/gyp/pylib/gyp/generator/msvs.py b/tools/gyp/pylib/gyp/generator/msvs.py index 5af21b37c255d0..fd950057847980 100644 --- a/tools/gyp/pylib/gyp/generator/msvs.py +++ b/tools/gyp/pylib/gyp/generator/msvs.py @@ -756,7 +756,7 @@ def _EscapeEnvironmentVariableExpansion(s): Returns: The escaped string. - """ + """ # noqa: E731,E123,E501 s = s.replace("%", "%%") return s diff --git a/tools/gyp/pylib/gyp/generator/ninja.py b/tools/gyp/pylib/gyp/generator/ninja.py index d51c64230b7c72..3db3771ac97855 100644 --- a/tools/gyp/pylib/gyp/generator/ninja.py +++ b/tools/gyp/pylib/gyp/generator/ninja.py @@ -2533,7 +2533,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name description="SOLINK $lib", restat=True, command=mtime_preserving_solink_base - % {"suffix": "@$link_file_list"}, + % {"suffix": "@$link_file_list"}, # noqa: E501 rspfile="$link_file_list", rspfile_content=( "-Wl,--whole-archive $in $solibs -Wl," "--no-whole-archive $libs" diff --git a/tools/gyp/pylib/gyp/xcode_emulation.py b/tools/gyp/pylib/gyp/xcode_emulation.py index 35062211a59307..a75d8eeab7bda0 100644 --- a/tools/gyp/pylib/gyp/xcode_emulation.py +++ b/tools/gyp/pylib/gyp/xcode_emulation.py @@ -1733,7 +1733,7 @@ def _GetXcodeEnv( "CONFIGURATION": configuration, "PRODUCT_NAME": xcode_settings.GetProductName(), # For FULL_PRODUCT_NAME see: - # /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\ Product\ Types.xcspec + # /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\ Product\ Types.xcspec # noqa: E501 "SRCROOT": srcroot, "SOURCE_ROOT": "${SRCROOT}", # This is not true for static libraries, but currently the env is only diff --git a/tools/gyp/pylib/gyp/xcodeproj_file.py b/tools/gyp/pylib/gyp/xcodeproj_file.py index 62fb53646f7cdc..076eea37211179 100644 --- a/tools/gyp/pylib/gyp/xcodeproj_file.py +++ b/tools/gyp/pylib/gyp/xcodeproj_file.py @@ -2770,7 +2770,7 @@ def __init__(self, properties=None, id=None, parent=None, path=None): self.path = path self._other_pbxprojects = {} # super - XCContainerPortal.__init__(self, properties, id, parent) + return XCContainerPortal.__init__(self, properties, id, parent) def Name(self): name = self.path diff --git a/tools/icu/shrink-icu-src.py b/tools/icu/shrink-icu-src.py index 30d34070c9ae17..3a9ba2fbfbf118 100644 --- a/tools/icu/shrink-icu-src.py +++ b/tools/icu/shrink-icu-src.py @@ -48,7 +48,7 @@ def print_size(fn): size = (os.stat(fn).st_size) / 1024000 print('%dM\t%s' % (size, fn)) -ignore_regex = re.compile('^.*\\.(vcxproj|filters|nrm|icu|dat|xml|txt|ac|guess|m4|in|sub|py|mak)$') +ignore_regex = re.compile('^.*\.(vcxproj|filters|nrm|icu|dat|xml|txt|ac|guess|m4|in|sub|py|mak)$') def icu_ignore(dir, files): subdir = dir[len(options.icusrc)+1::] diff --git a/tools/mkssldef.py b/tools/mkssldef.py index 6b60142bb86baf..4768d1ff0ff699 100755 --- a/tools/mkssldef.py +++ b/tools/mkssldef.py @@ -26,7 +26,7 @@ for filename in filenames: for line in open(filename).readlines(): - name, _, _, meta, _ = re.split('\\s+', line) + name, _, _, meta, _ = re.split('\s+', line) if any(p.match(name) for p in excludes): continue meta = meta.split(':') assert meta[0] in ('EXIST', 'NOEXIST')