Skip to content
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

used-before-assignment is not always triggered #267

Closed
pylint-bot opened this issue Jun 26, 2014 · 2 comments
Closed

used-before-assignment is not always triggered #267

pylint-bot opened this issue Jun 26, 2014 · 2 comments
Labels
Bug 🪲 Checkers Related to a checker Control flow Requires control flow understanding Duplicate 🐫 Duplicate of an already existing issue

Comments

@pylint-bot
Copy link

pylint-bot commented Jun 26, 2014

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


For the following code:

class A(object):

    def __init__(self):

        self.a = True

    def method(self):

        if not self.a:
            test = 1
            dest = test + 2
        else:
            # UnboundLocalError: local variable 'test' referenced before assignment
            dest = test + 3
            test = 1


if __name__ == "__main__":
    a = A()
    a.method()

Maybe we can detect that test is conditionally defined.


@pylint-bot pylint-bot added Bug 🪲 Checkers Related to a checker labels Dec 9, 2015
@rogalski
Copy link
Contributor

rogalski commented Jan 2, 2017

Should be labeled with flow_control

@Pierre-Sassoulas
Copy link
Member

Closing as a duplicate of #1727, it's old but the discussion happened elsewhere. (Thank you @jacobtylerwalls for helping us cleanup)

@Pierre-Sassoulas Pierre-Sassoulas added the Duplicate 🐫 Duplicate of an already existing issue label Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Checkers Related to a checker Control flow Requires control flow understanding Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

4 participants