Skip to content

used-before-assignment for assignment in inner try when outer try returns #8686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jacobtylerwalls opened this issue May 15, 2023 · 0 comments
Labels
C: used-before-assignment Issues related to 'used-before-assignment' check Control flow Requires control flow understanding False Positive 🦟 A message is emitted but nothing is wrong with the code

Comments

@jacobtylerwalls
Copy link
Member

Bug description

Looks like #5506 missed nested try blocks when accounting for (outer) try blocks that return.

def test():
    try:
        return [1 / 0]
    except ZeroDivisionError:
        try:
            results = []
        finally:
            pass
    return results  # raises used-before-assignment

Configuration

No response

Command used

pylint a.py

Pylint output

************* Module a
a.py:9:11: E0601: Using variable 'results' before assignment (used-before-assignment)

Expected behavior

no msg

Pylint version

pylint 3.0.0b1
astroid 3.0.0a4-dev0
Python 3.11.2

OS / Environment

No response

Additional dependencies

No response

@jacobtylerwalls jacobtylerwalls added Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling False Positive 🦟 A message is emitted but nothing is wrong with the code C: used-before-assignment Issues related to 'used-before-assignment' check labels May 15, 2023
@jacobtylerwalls jacobtylerwalls removed the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Aug 13, 2023
@jacobtylerwalls jacobtylerwalls added the Control flow Requires control flow understanding label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: used-before-assignment Issues related to 'used-before-assignment' check Control flow Requires control flow understanding False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

No branches or pull requests

1 participant