Skip to content

Commit 90c6c33

Browse files
committed
Don't create lists only to access the first item
RUF015: 'Prefer `next(iter(...))` over single element slice'
1 parent 2b890ea commit 90c6c33

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/briefcase/commands/dev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def __call__(
230230
# in pyproject.toml, then we can use it as a default;
231231
# otherwise look for a -a/--app option.
232232
if len(self.apps) == 1:
233-
app = list(self.apps.values())[0]
233+
app = next(iter(self.apps.values()))
234234
elif appname:
235235
try:
236236
app = self.apps[appname]

src/briefcase/commands/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def __call__(
278278
# in pyproject.toml, then we can use it as a default;
279279
# otherwise look for a -a/--app option.
280280
if len(self.apps) == 1:
281-
app = list(self.apps.values())[0]
281+
app = next(iter(self.apps.values()))
282282
elif appname:
283283
try:
284284
app = self.apps[appname]

src/briefcase/platforms/iOS/xcode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def select_target_device(self, udid_or_device=None):
213213
if len(simulators) == 0:
214214
raise BriefcaseCommandError("No iOS simulators available.")
215215
elif len(simulators) == 1:
216-
iOS_tag = list(simulators.keys())[0]
216+
iOS_tag = next(iter(simulators.keys()))
217217
else:
218218
iOS_tag = self.console.selection_question(
219219
intro="Select iOS version:",
@@ -226,7 +226,7 @@ def select_target_device(self, udid_or_device=None):
226226
if len(devices) == 0:
227227
raise BriefcaseCommandError(f"No simulators available for {iOS_tag}.")
228228
elif len(devices) == 1:
229-
udid = list(devices.keys())[0]
229+
udid = next(iter(devices.keys()))
230230
else:
231231
udid = self.console.selection_question(
232232
intro="Select simulator device to use:",

0 commit comments

Comments
 (0)