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

Suppress not-an-iterable for model_utils.managers. Fixes #117 #143

Merged
merged 4 commits into from
Apr 5, 2018

Conversation

atodorov
Copy link
Contributor

I don't have experience with django-model-utils and I wasn't able to figure out why it produces this error. My search boiled down to IterableChecker._check_iterable inside pylint. After executing infered = safe_infered(node) I get:

  1. None when the code under evaluation is a standard Django objects manager
  2. Const.NoneType(value=None) when inspecting the .all() of an InheritanceManager

Another possibility is to add a transformation similar to pylint_django/transforms/transforms/django_db_models.py which sets all of the same attributes of InheritanceManager (and friends).

In fact I think I may go ahead with the transformation option instead of this one. @carlio can I inherit the new transformation class from the above one or do I need to copy everything ?

@coveralls
Copy link

coveralls commented Mar 23, 2018

Pull Request Test Coverage Report for Build 354

  • 0 of 0 (NaN%) changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 86.606%

Totals Coverage Status
Change from base Build 350: -0.01%
Covered Lines: 472
Relevant Lines: 545

💛 - Coveralls

@atodorov
Copy link
Contributor Author

@carlio I'm not quire sure how to use the _attribute_is_magic function. Can you take a look?

I'd prefer to actually be able to check the type of the node being one of several known managers instead of blindly disabling the pylint errors when the attribute is named objects.

Note: this same augmentation function will also fix #144. Also notice that we have the not-an-iterable error reported when the objects manager is defined as class attribute regardless of what the actual manager class is.

the way we do this is by modifying our transformations to return
an empty list instead of None.
@atodorov atodorov merged commit 442d575 into master Apr 5, 2018
@atodorov atodorov deleted the issue-117 branch April 5, 2018 22:20
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.

None yet

3 participants