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

Schema.extend is not compatible with Schema subclasses (affects pytest-voluptuous) #370

Closed
himikof opened this issue Dec 6, 2018 · 2 comments
Assignees

Comments

@himikof
Copy link

himikof commented Dec 6, 2018

The pytest-voluptuous integration package makes use of a Schema subclass (S) to implement concise pytest assertion syntax.
It looks like this:

   assert S({
      'info': Partial({
          'package_url': 'https://pypi.org/project/pytest/',
          'platform': 'INVALID VALUE',
          'description': Length(max=10),
          'downloads': list,
          'classifiers': dict,
      }),
      'releases': dict,
      'urls': int
   }) == resp.json()

But the problem is that the S(...).extend returns Schema, not S, which breaks pytest integration after using extend.
If Schema.extend behaved more like a @classmethod and returned an instance of type(self), this use case would just work.

@alecthomas
Copy link
Owner

Seems reasonable. PRs welcome.

svisser added a commit to svisser/voluptuous that referenced this issue Dec 28, 2018
This updates the extend method to return the same type in case
a subclass of Schema has been constructed.

This is a change related to issue alecthomas#370.
@svisser svisser self-assigned this Dec 28, 2018
@svisser
Copy link
Collaborator

svisser commented Dec 31, 2018

@himikof thanks for reporting this issue!

There is now a fix for this on the master branch so I'm closing this issue: e11b20a.

@svisser svisser closed this as completed Dec 31, 2018
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

No branches or pull requests

3 participants