Just a formatting issue but you could make the 'role list' first and use it in the expression which would reduce the line length substantially. Same for `_is_pm_or_pi` above. Also the `True if` is redundant.