Skip to content

Commit db89089

Browse files
authoredNov 25, 2024··
ruff rule PLC0206 and RUF021 (#270)
* ruff rule PLC0206 * All checks passed! for ruff rule RUF021
1 parent 2ff6d36 commit db89089

9 files changed

+23
-26
lines changed
 

‎pylib/gyp/MSVSSettings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def ValidateMSBuild(self, value):
171171
int(value, self._msbuild_base)
172172

173173
def ConvertToMSBuild(self, value):
174-
msbuild_format = (self._msbuild_base == 10) and "%d" or "0x%04x"
174+
msbuild_format = ((self._msbuild_base == 10) and "%d") or "0x%04x"
175175
return msbuild_format % int(value)
176176

177177

‎pylib/gyp/MSVSVersion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def UsesVcxproj(self):
6969

7070
def ProjectExtension(self):
7171
"""Returns the file extension for the project."""
72-
return self.uses_vcxproj and ".vcxproj" or ".vcproj"
72+
return (self.uses_vcxproj and ".vcxproj") or ".vcproj"
7373

7474
def Path(self):
7575
"""Returns the path to Visual Studio installation."""

‎pylib/gyp/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def Noop(value):
253253
for name, metadata in options._regeneration_metadata.items():
254254
opt = metadata["opt"]
255255
value = getattr(options, name)
256-
value_predicate = metadata["type"] == "path" and FixPath or Noop
256+
value_predicate = (metadata["type"] == "path" and FixPath) or Noop
257257
action = metadata["action"]
258258
env_name = metadata["env_name"]
259259
if action == "append":

‎pylib/gyp/generator/make.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ def __init__(self, generator_flags, flavor):
788788
self.suffix_rules_objdir2 = {}
789789

790790
# Generate suffix rules for all compilable extensions.
791-
for ext in COMPILABLE_EXTENSIONS:
791+
for ext, value in COMPILABLE_EXTENSIONS.items():
792792
# Suffix rules for source folder.
793793
self.suffix_rules_srcdir.update(
794794
{
@@ -797,7 +797,7 @@ def __init__(self, generator_flags, flavor):
797797
$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD
798798
\t@$(call do_cmd,%s,1)
799799
"""
800-
% (ext, COMPILABLE_EXTENSIONS[ext])
800+
% (ext, value)
801801
)
802802
}
803803
)
@@ -810,7 +810,7 @@ def __init__(self, generator_flags, flavor):
810810
$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD
811811
\t@$(call do_cmd,%s,1)
812812
"""
813-
% (ext, COMPILABLE_EXTENSIONS[ext])
813+
% (ext, value)
814814
)
815815
}
816816
)
@@ -821,7 +821,7 @@ def __init__(self, generator_flags, flavor):
821821
$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
822822
\t@$(call do_cmd,%s,1)
823823
"""
824-
% (ext, COMPILABLE_EXTENSIONS[ext])
824+
% (ext, value)
825825
)
826826
}
827827
)
@@ -1779,13 +1779,13 @@ def WriteTarget(
17791779
# using ":=".
17801780
self.WriteSortedXcodeEnv(self.output, self.GetSortedXcodePostbuildEnv())
17811781

1782-
for configname in target_postbuilds:
1782+
for configname, value in target_postbuilds.items():
17831783
self.WriteLn(
17841784
"%s: TARGET_POSTBUILDS_%s := %s"
17851785
% (
17861786
QuoteSpaces(self.output),
17871787
configname,
1788-
gyp.common.EncodePOSIXShellList(target_postbuilds[configname]),
1788+
gyp.common.EncodePOSIXShellList(value),
17891789
)
17901790
)
17911791

‎pylib/gyp/input.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -2469,11 +2469,8 @@ def SetUpConfigurations(target, target_dict):
24692469
merged_configurations[configuration] = new_configuration_dict
24702470

24712471
# Put the new configurations back into the target dict as a configuration.
2472-
for configuration in merged_configurations:
2473-
target_dict["configurations"][configuration] = merged_configurations[
2474-
configuration
2475-
]
2476-
2472+
for configuration, value in merged_configurations.items():
2473+
target_dict["configurations"][configuration] = value
24772474
# Now drop all the abstract ones.
24782475
configs = target_dict["configurations"]
24792476
target_dict["configurations"] = {
@@ -3020,8 +3017,8 @@ def Load(
30203017
del target_dict[key]
30213018
ProcessListFiltersInDict(target_name, tmp_dict)
30223019
# Write the results back to |target_dict|.
3023-
for key in tmp_dict:
3024-
target_dict[key] = tmp_dict[key]
3020+
for key, value in tmp_dict.items():
3021+
target_dict[key] = value
30253022

30263023
# Make sure every dependency appears at most once.
30273024
RemoveDuplicateDependencies(targets)

‎pylib/gyp/xcode_emulation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,8 @@ def _GetIOSPostbuilds(self, configname, output_binary):
11271127
be deployed to a device. This should be run as the very last step of the
11281128
build."""
11291129
if not (
1130-
self.isIOS
1131-
and (self.spec["type"] == "executable" or self._IsXCTest())
1130+
(self.isIOS
1131+
and (self.spec["type"] == "executable" or self._IsXCTest()))
11321132
or self.IsIosFramework()
11331133
):
11341134
return []

‎pylib/gyp/xcodeproj_file.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3017,10 +3017,10 @@ def _AllSymrootsUnique(self, target, inherit_unique_symroot):
30173017
symroots = self._DefinedSymroots(target)
30183018
for s in self._DefinedSymroots(target):
30193019
if (
3020-
s is not None
3021-
and not self._IsUniqueSymrootForTarget(s)
3022-
or s is None
3023-
and not inherit_unique_symroot
3020+
(s is not None
3021+
and not self._IsUniqueSymrootForTarget(s))
3022+
or (s is None
3023+
and not inherit_unique_symroot)
30243024
):
30253025
return False
30263026
return True if symroots else inherit_unique_symroot

‎tools/pretty_sln.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ def ParseSolution(solution_file):
9393
continue
9494

9595
# Change all dependencies clsid to name instead.
96-
for project in dependencies:
96+
for project, deps in dependencies.items():
9797
# For each dependencies in this project
9898
new_dep_array = []
99-
for dep in dependencies[project]:
99+
for dep in deps:
100100
# Look for the project name matching this cldis
101101
for project_info in projects:
102102
if projects[project_info][1] == dep:

‎tools/pretty_vcproj.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ def FixFilenames(filenames, current_directory):
118118
new_list = []
119119
for filename in filenames:
120120
if filename:
121-
for key in REPLACEMENTS:
122-
filename = filename.replace(key, REPLACEMENTS[key])
121+
for key, value in REPLACEMENTS.items():
122+
filename = filename.replace(key, value)
123123
os.chdir(current_directory)
124124
filename = filename.strip("\"' ")
125125
if filename.startswith("$"):

0 commit comments

Comments
 (0)
Please sign in to comment.