Closed Bug 1811019 Opened 2 years ago Closed 2 years ago

use `all` and `any` Python builtins instead of checking for `None in list` etc

Categories

(Conduit :: moz-phab, task)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: sheehan, Assigned: sheehan)

Details

Attachments

(6 files)

moz-phab has a few usages of un-Pythonic idioms to check for invalid values. For example in this if statement we create a list of all the type keys and then re-iterate over the list to see if "abandon" in list is True. We should be using any with a generator, which is more efficient and easier to understand.

Use any function with a passed generator instead of
building a list and then looking for the value in the
list.

Sets are faster for __contains__ operations.

Depends on D167178

Both branches do the same thing, so reduce to the more
generic option to simplify.

Depends on D167179

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: