Skip to content

Commit 87677a5

Browse files
committed
chore: ruff format Python code
1 parent 1ee15f5 commit 87677a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2006
-2037
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- uses: astral-sh/ruff-action@v3
2222
with:
2323
args: "check --select=E,F,PLC,PLE,UP,W,YTT --ignore=E721,PLC0206,PLC0415,PLC1901,S101,UP031 --target-version=py39"
24+
- run: ruff format --check --diff
2425

2526
lint-js:
2627
name: Lint JS

gyp/pylib/gyp/MSVSNew.py

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ def cmp(x, y):
3232
def MakeGuid(name, seed="msvs_new"):
3333
"""Returns a GUID for the specified target name.
3434
35-
Args:
36-
name: Target name.
37-
seed: Seed for MD5 hash.
38-
Returns:
39-
A GUID-line string calculated from the name and seed.
40-
41-
This generates something which looks like a GUID, but depends only on the
42-
name and seed. This means the same name/seed will always generate the same
43-
GUID, so that projects and solutions which refer to each other can explicitly
44-
determine the GUID to refer to explicitly. It also means that the GUID will
45-
not change when the project for a target is rebuilt.
46-
"""
35+
Args:
36+
name: Target name.
37+
seed: Seed for MD5 hash.
38+
Returns:
39+
A GUID-line string calculated from the name and seed.
40+
41+
This generates something which looks like a GUID, but depends only on the
42+
name and seed. This means the same name/seed will always generate the same
43+
GUID, so that projects and solutions which refer to each other can explicitly
44+
determine the GUID to refer to explicitly. It also means that the GUID will
45+
not change when the project for a target is rebuilt.
46+
"""
4747
# Calculate a MD5 signature for the seed and name.
4848
d = hashlib.md5((str(seed) + str(name)).encode("utf-8")).hexdigest().upper()
4949
# Convert most of the signature to GUID form (discard the rest)
@@ -78,15 +78,15 @@ class MSVSFolder(MSVSSolutionEntry):
7878
def __init__(self, path, name=None, entries=None, guid=None, items=None):
7979
"""Initializes the folder.
8080
81-
Args:
82-
path: Full path to the folder.
83-
name: Name of the folder.
84-
entries: List of folder entries to nest inside this folder. May contain
85-
Folder or Project objects. May be None, if the folder is empty.
86-
guid: GUID to use for folder, if not None.
87-
items: List of solution items to include in the folder project. May be
88-
None, if the folder does not directly contain items.
89-
"""
81+
Args:
82+
path: Full path to the folder.
83+
name: Name of the folder.
84+
entries: List of folder entries to nest inside this folder. May contain
85+
Folder or Project objects. May be None, if the folder is empty.
86+
guid: GUID to use for folder, if not None.
87+
items: List of solution items to include in the folder project. May be
88+
None, if the folder does not directly contain items.
89+
"""
9090
if name:
9191
self.name = name
9292
else:
@@ -128,19 +128,19 @@ def __init__(
128128
):
129129
"""Initializes the project.
130130
131-
Args:
132-
path: Absolute path to the project file.
133-
name: Name of project. If None, the name will be the same as the base
134-
name of the project file.
135-
dependencies: List of other Project objects this project is dependent
136-
upon, if not None.
137-
guid: GUID to use for project, if not None.
138-
spec: Dictionary specifying how to build this project.
139-
build_file: Filename of the .gyp file that the vcproj file comes from.
140-
config_platform_overrides: optional dict of configuration platforms to
141-
used in place of the default for this target.
142-
fixpath_prefix: the path used to adjust the behavior of _fixpath
143-
"""
131+
Args:
132+
path: Absolute path to the project file.
133+
name: Name of project. If None, the name will be the same as the base
134+
name of the project file.
135+
dependencies: List of other Project objects this project is dependent
136+
upon, if not None.
137+
guid: GUID to use for project, if not None.
138+
spec: Dictionary specifying how to build this project.
139+
build_file: Filename of the .gyp file that the vcproj file comes from.
140+
config_platform_overrides: optional dict of configuration platforms to
141+
used in place of the default for this target.
142+
fixpath_prefix: the path used to adjust the behavior of _fixpath
143+
"""
144144
self.path = path
145145
self.guid = guid
146146
self.spec = spec
@@ -195,16 +195,16 @@ def __init__(
195195
):
196196
"""Initializes the solution.
197197
198-
Args:
199-
path: Path to solution file.
200-
version: Format version to emit.
201-
entries: List of entries in solution. May contain Folder or Project
202-
objects. May be None, if the folder is empty.
203-
variants: List of build variant strings. If none, a default list will
204-
be used.
205-
websiteProperties: Flag to decide if the website properties section
206-
is generated.
207-
"""
198+
Args:
199+
path: Path to solution file.
200+
version: Format version to emit.
201+
entries: List of entries in solution. May contain Folder or Project
202+
objects. May be None, if the folder is empty.
203+
variants: List of build variant strings. If none, a default list will
204+
be used.
205+
websiteProperties: Flag to decide if the website properties section
206+
is generated.
207+
"""
208208
self.path = path
209209
self.websiteProperties = websiteProperties
210210
self.version = version
@@ -230,9 +230,9 @@ def __init__(
230230
def Write(self, writer=gyp.common.WriteOnDiff):
231231
"""Writes the solution file to disk.
232232
233-
Raises:
234-
IndexError: An entry appears multiple times.
235-
"""
233+
Raises:
234+
IndexError: An entry appears multiple times.
235+
"""
236236
# Walk the entry tree and collect all the folders and projects.
237237
all_entries = set()
238238
entries_to_check = self.entries[:]

gyp/pylib/gyp/MSVSProject.py

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ class Tool:
1515
def __init__(self, name, attrs=None):
1616
"""Initializes the tool.
1717
18-
Args:
19-
name: Tool name.
20-
attrs: Dict of tool attributes; may be None.
21-
"""
18+
Args:
19+
name: Tool name.
20+
attrs: Dict of tool attributes; may be None.
21+
"""
2222
self._attrs = attrs or {}
2323
self._attrs["Name"] = name
2424

2525
def _GetSpecification(self):
2626
"""Creates an element for the tool.
2727
28-
Returns:
29-
A new xml.dom.Element for the tool.
30-
"""
28+
Returns:
29+
A new xml.dom.Element for the tool.
30+
"""
3131
return ["Tool", self._attrs]
3232

3333

@@ -37,10 +37,10 @@ class Filter:
3737
def __init__(self, name, contents=None):
3838
"""Initializes the folder.
3939
40-
Args:
41-
name: Filter (folder) name.
42-
contents: List of filenames and/or Filter objects contained.
43-
"""
40+
Args:
41+
name: Filter (folder) name.
42+
contents: List of filenames and/or Filter objects contained.
43+
"""
4444
self.name = name
4545
self.contents = list(contents or [])
4646

@@ -54,13 +54,13 @@ class Writer:
5454
def __init__(self, project_path, version, name, guid=None, platforms=None):
5555
"""Initializes the project.
5656
57-
Args:
58-
project_path: Path to the project file.
59-
version: Format version to emit.
60-
name: Name of the project.
61-
guid: GUID to use for project, if not None.
62-
platforms: Array of string, the supported platforms. If null, ['Win32']
63-
"""
57+
Args:
58+
project_path: Path to the project file.
59+
version: Format version to emit.
60+
name: Name of the project.
61+
guid: GUID to use for project, if not None.
62+
platforms: Array of string, the supported platforms. If null, ['Win32']
63+
"""
6464
self.project_path = project_path
6565
self.version = version
6666
self.name = name
@@ -84,21 +84,21 @@ def __init__(self, project_path, version, name, guid=None, platforms=None):
8484
def AddToolFile(self, path):
8585
"""Adds a tool file to the project.
8686
87-
Args:
88-
path: Relative path from project to tool file.
89-
"""
87+
Args:
88+
path: Relative path from project to tool file.
89+
"""
9090
self.tool_files_section.append(["ToolFile", {"RelativePath": path}])
9191

9292
def _GetSpecForConfiguration(self, config_type, config_name, attrs, tools):
9393
"""Returns the specification for a configuration.
9494
95-
Args:
96-
config_type: Type of configuration node.
97-
config_name: Configuration name.
98-
attrs: Dict of configuration attributes; may be None.
99-
tools: List of tools (strings or Tool objects); may be None.
100-
Returns:
101-
"""
95+
Args:
96+
config_type: Type of configuration node.
97+
config_name: Configuration name.
98+
attrs: Dict of configuration attributes; may be None.
99+
tools: List of tools (strings or Tool objects); may be None.
100+
Returns:
101+
"""
102102
# Handle defaults
103103
if not attrs:
104104
attrs = {}
@@ -122,23 +122,23 @@ def _GetSpecForConfiguration(self, config_type, config_name, attrs, tools):
122122
def AddConfig(self, name, attrs=None, tools=None):
123123
"""Adds a configuration to the project.
124124
125-
Args:
126-
name: Configuration name.
127-
attrs: Dict of configuration attributes; may be None.
128-
tools: List of tools (strings or Tool objects); may be None.
129-
"""
125+
Args:
126+
name: Configuration name.
127+
attrs: Dict of configuration attributes; may be None.
128+
tools: List of tools (strings or Tool objects); may be None.
129+
"""
130130
spec = self._GetSpecForConfiguration("Configuration", name, attrs, tools)
131131
self.configurations_section.append(spec)
132132

133133
def _AddFilesToNode(self, parent, files):
134134
"""Adds files and/or filters to the parent node.
135135
136-
Args:
137-
parent: Destination node
138-
files: A list of Filter objects and/or relative paths to files.
136+
Args:
137+
parent: Destination node
138+
files: A list of Filter objects and/or relative paths to files.
139139
140-
Will call itself recursively, if the files list contains Filter objects.
141-
"""
140+
Will call itself recursively, if the files list contains Filter objects.
141+
"""
142142
for f in files:
143143
if isinstance(f, Filter):
144144
node = ["Filter", {"Name": f.name}]
@@ -151,29 +151,29 @@ def _AddFilesToNode(self, parent, files):
151151
def AddFiles(self, files):
152152
"""Adds files to the project.
153153
154-
Args:
155-
files: A list of Filter objects and/or relative paths to files.
154+
Args:
155+
files: A list of Filter objects and/or relative paths to files.
156156
157-
This makes a copy of the file/filter tree at the time of this call. If you
158-
later add files to a Filter object which was passed into a previous call
159-
to AddFiles(), it will not be reflected in this project.
160-
"""
157+
This makes a copy of the file/filter tree at the time of this call. If you
158+
later add files to a Filter object which was passed into a previous call
159+
to AddFiles(), it will not be reflected in this project.
160+
"""
161161
self._AddFilesToNode(self.files_section, files)
162162
# TODO(rspangler) This also doesn't handle adding files to an existing
163163
# filter. That is, it doesn't merge the trees.
164164

165165
def AddFileConfig(self, path, config, attrs=None, tools=None):
166166
"""Adds a configuration to a file.
167167
168-
Args:
169-
path: Relative path to the file.
170-
config: Name of configuration to add.
171-
attrs: Dict of configuration attributes; may be None.
172-
tools: List of tools (strings or Tool objects); may be None.
168+
Args:
169+
path: Relative path to the file.
170+
config: Name of configuration to add.
171+
attrs: Dict of configuration attributes; may be None.
172+
tools: List of tools (strings or Tool objects); may be None.
173173
174-
Raises:
175-
ValueError: Relative path does not match any file added via AddFiles().
176-
"""
174+
Raises:
175+
ValueError: Relative path does not match any file added via AddFiles().
176+
"""
177177
# Find the file node with the right relative path
178178
parent = self.files_dict.get(path)
179179
if not parent:

0 commit comments

Comments
 (0)