Skip to content

pylint doesn't understand the scope of except clause variables #626

@pylint-bot

Description

@pylint-bot

Originally reported by: Tom Dryer (BitBucket: tdryer, GitHub: @tdryer?)


In the following code, pylint fails to identify that the e in the except clause is an unused variable, and that the e in print(e) is an undefined variable:

#!python

def main():
    try:
        raise ValueError
    except ValueError as e:
        pass

    print(e)


main()

The issue appears to be that pylint doesn't understand that the scope of the exception variable is limited to the except clause.


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions