Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix FilterSet proxy#4620

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lovelydinosaur merged 3 commits intoencode:masterfromspearki:filterset-proxy
Nov 1, 2016
Merged

Conversation

@spearki
Copy link
Contributor

Description

Fix FilterSet proxying to be aware of parent metaclasses.

Closes#4619.

rpkilby reacted with thumbs up emoji
Copy link
Contributor

@lovelydinosaurlovelydinosaur left a comment

Choose a reason for hiding this comment

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

Great work on resolving this! One minor proposed change as above - let us know if you think the proposal doesn't make sense in some way, but otherwise I think it's worth us making sure that we're able to give friendly error messages in the case thedjango-filter isn't installed.

returnsuper(FilterSetMetaclass,cls).__new__(cls,name,bases,attrs)

classFilterSet(six.with_metaclass(FilterSetMetaclass,DFFilterSet)):
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

For user-friendlyness we should also have a branch that includes the case where django_filters isn't is installed so thatFilterSet imports still succeed, but raise an assertion error letting the user know that they need to installdjango-filter.

Copy link
Contributor

@lovelydinosaurlovelydinosaurOct 24, 2016
edited
Loading

Choose a reason for hiding this comment

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

This could just be...

if django_filters:    ...else:    def FilterSet(*args, **kwargs):        assert False, 'django-filter must be installed to use the `FilterSet` class'

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Makes sense. I've added a commit for this. It's a bit complicated since FilterSet is designed to be subclassed, so getting a nice error message at the point of use needed another metaclass.

ifbases!= (object,):
assertFalse,'django-filter must be installed to use the `FilterSet` class'
super(FilterSetMetaclass,self).__init__(name,bases,attrs)
_BaseFilterSet=object
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if it'd be marginally cleaner to haveFilterSet declarationinside theif case, rather thanafter it.

Then theelse case could just have aFilterSet stub that raises an assertion error, rather than having aFilterSet metaclass.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

The metaclass is required if we want the assert to fire whenFilterSet is subclassed. That way the context of the error is at the actual point of use. Another alternative is a dummy class with an assert in__init__, but then the error won't happen until you hit the view.

@lovelydinosaur
Copy link
Contributor

Reckon we're good to go with this. Anyone else want to chime in?

@spearki
Copy link
ContributorAuthor

So for the coverage stuff. How do you feel about adding a new tox envpy27-bare that skips the requirements-optional.txt install?

@lovelydinosaur
Copy link
Contributor

How do you feel about adding a new tox env py27-bare that skips the requirements-optional.txt install?

I don't understand what that'd change / resolve. I think we just want to turn off or dial down the coverage tests at some point. It's useful to see the changes, but I don't really want it passing or failing a pull request.

@lovelydinosaurlovelydinosaur merged commit98df932 intoencode:masterNov 1, 2016
@lovelydinosaur
Copy link
Contributor

Great stuff, thanks for your work on this!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@lovelydinosaurlovelydinosaurlovelydinosaur requested changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

3.5.2 Release

Development

Successfully merging this pull request may close these issues.

2 participants

@spearki@lovelydinosaur

[8]ページ先頭

©2009-2025 Movatter.jp