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

FK as string from models as package fails with "UnboundLocalError: local variable 'key_cls' referenced before assignment" #229

Merged

Conversation

imomaliev
Copy link
Contributor

@imomaliev imomaliev commented Apr 21, 2019

Currently ForeignKey inferring fails with UnboundLocalError: local variable 'key_cls' referenced before assignment for cases when models is a python package, the to argument is a string that is used in this pattern app.Model and also there is some other bool const like null=True right after to.

@imomaliev imomaliev changed the title failing tests for FK as string from models as package FK as string from models as package fails with "UnboundLocalError: local variable 'key_cls' referenced before assignment" Apr 21, 2019
@coveralls
Copy link

coveralls commented Apr 21, 2019

Pull Request Test Coverage Report for Build 681

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 87.396%

Totals Coverage Status
Change from base Build 665: 0.5%
Covered Lines: 631
Relevant Lines: 722

💛 - Coveralls

@imomaliev imomaliev force-pushed the fix-inferring-of-fk-for-package-models branch 5 times, most recently from b6f1b11 to 859d658 Compare April 23, 2019 15:18
@imomaliev imomaliev force-pushed the fix-inferring-of-fk-for-package-models branch from 859d658 to 87f9b4c Compare April 23, 2019 15:19
Copy link
Contributor

@atodorov atodorov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks very good, minor changes requested.

CHANGELOG.rst Outdated Show resolved Hide resolved
pylint_django/tests/input/models/author.py Show resolved Hide resolved
pylint_django/tests/test_func.py Outdated Show resolved Hide resolved
@atodorov
Copy link
Contributor

@imomaliev is this by any chance the fix for #198 ? If so please add 'Fix #198' to one of the commit messages and GitHub will close it automatically.

@imomaliev
Copy link
Contributor Author

imomaliev commented Apr 24, 2019

@atodorov made requested changes and moved tests to input folder, models package is still required(see #229 (comment)). Regarding #198, looks like it is related and should probably fix it. But what OP is asking for is separate error code for cases when models are not loaded in astroid for some reason. I suggest closing until another issues related to this emerge. Should I add "fix #198" to commit message?

@atodorov atodorov merged commit b99f53e into pylint-dev:master Apr 26, 2019
@prokher
Copy link

prokher commented Apr 26, 2019

Just received the same error in 2.0.9.

@carlio
Copy link
Collaborator

carlio commented Apr 26, 2019

Also here - #232

@zout
Copy link

zout commented May 8, 2019

Also posted in #232 but no response yet. But I've narrowed it down to OneToOne relations. On my github there is a project that will trigger the error. Hope it helps in finding out the root cause: https://github.com/zout/django-pylint-issue

@imomaliev imomaliev deleted the fix-inferring-of-fk-for-package-models branch November 8, 2022 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants