Skip to content

used-before-assignment false positive for named expressions in a not-first position in container #8252

Closed
@jacobtylerwalls

Description

@jacobtylerwalls

This raises used-before-assignment:

def expression_in_ternary_operator_inside_container_later_position():
    """Named expression follows unrelated item in container"""
    return [23, val3 if (val3 := 'something') else 'anything']

The check for BaseContainer should also check all elements. I can handle that in another PR.

Originally posted by @jacobtylerwalls in #8176 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: used-before-assignmentIssues related to 'used-before-assignment' checkFalse Positive 🦟A message is emitted but nothing is wrong with the code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions