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

Add methods and members to ManyToManyField #28

Merged
merged 1 commit into from
Oct 1, 2014

Conversation

mbarrien
Copy link
Contributor

My code uses some methods and members on ManyToMany fields that pylint-django doesn't represent in the transformed class. This pull request adds those and more.

I most care about add(), clear() and through existing.

However, I went into Django source code at https://github.com/django/django/blob/1.7/django/db/models/fields/related.py and extracted all the public methods and members from the dynamically generated ManyRelatedManager, only omitting those members/methods which overlapped with those in QuerySet which is already inherited from.

This solves my problem, but does have the potential of being problematic for these reasons:

  • Since the fields are returning None and no method bodies exist, the type inference in pylint may end up incorrect. I think this precedent has been set by the other transformations.
  • get_queryset and get_prefetch_queryset have different name get_query_set/get_prefetch_query_set in the Django 1.5 series and earlier. For now, I've just assumed 1.6+ compatibility.
  • add() and remove() may not exist for ManyToMany fields "if the ManyToMany relation has an intermediary model" in Django 1.6 series and below. I think this is okay because in 1.7 the methods always exist but raise exceptions if called in those situations; however 1.6 and earlier code may end up with false negatives if analyzing code that attempts to call add() and remove() where this situation applies.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 2ec2023 on mbarrien:manytomany-methods into 0dd642c on landscapeio:master.

carlio added a commit that referenced this pull request Oct 1, 2014
Add methods and members to ManyToManyField
@carlio carlio merged commit 1c8b2b4 into pylint-dev:master Oct 1, 2014
@mbarrien mbarrien deleted the manytomany-methods branch October 1, 2014 05: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.

3 participants