Just because you can do something, doesn't mean you should, and that's the case with nested conditional expressions. Nesting conditional expressions results in the kind of code that may seem clear as day when you write it, but six months later will leave maintainers (or worse - future you) scratching their heads and cursing.

Instead, err on the side of clarity, and use another line to express the nested operation as a separate statement.

Noncompliant Code Example

def get_title(person):
    return "Mr. " if person.gender == Person.MALE else "Mrs. " if person.is_married() else "Miss "  # Noncompliant

Compliant Solution

def get_title(person):
    if person.gender == Person.MALE:
        return "Mr. "
    return "Mrs. " if person.is_married() else "Miss "

Exceptions

No issue is raised on conditional expressions in comprehensions.