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

DEFAULT_TYPES cannot be used on Validators using TypeCheckers with 4.0.0 #523

Closed
retr0h opened this issue Mar 3, 2020 · 7 comments
Closed
Labels

Comments

@retr0h
Copy link

retr0h commented Mar 3, 2020

Describe the bug

Seeing the following error as soon as we started using 4.0.0.

self = <class 'jsonschema.validators.create.<locals>.Validator'>

    def _DEFAULT_TYPES(self):
        if self._CREATED_WITH_DEFAULT_TYPES is None:
>           raise _DontDoThat()
E           jsonschema.validators._DontDoThat: DEFAULT_TYPES cannot be used on Validators using TypeCheckers

self       = <class 'jsonschema.validators.create.<locals>.Validator'>

How To Reproduce

import contextlib

import flask_restx

@contextlib.contextmanager
def open_file(filename, mode='r'):
    with open(filename, mode) as stream:
        yield stream

def test_open_file(fs):
    f = 'foo.txt'
    fs.create_file(f, contents='foo')

    with open_file(f) as stream:
        assert 'foo' == stream.read()

Your enviroment
Please run the following and paste the output.

Darwin-19.3.0-x86_64-i386-64bit

Python 3.7.6 (default, Jan 15 2020, 13:46:19)
[Clang 11.0.0 (clang-1100.0.33.17)]

pyfakefs 4.0.0
@retr0h
Copy link
Author

retr0h commented Mar 3, 2020

Ahh... looks to be related to flask-restx. As soon as my tests are loaded which use flask-restx, I get the error reported above.

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Mar 3, 2020

We're used to get issues right after a release, but that was really fast... can you elaborate on that? Can we reproduce this?

@retr0h
Copy link
Author

retr0h commented Mar 3, 2020

We're used to get issues right after a release, but that was really fast... can you elaborate on that? Can we reproduce this?

HAHAH I was working on a project which uses this project quite a bit :) Thanks CI lol

I updated the example above. It looks as though simply importing flask_restx introduces the issue.

@mrbean-bremen
Copy link
Member

I guess you would like a patch release with the fix?

@mrbean-bremen
Copy link
Member

Can you please check if it works for you with current master?

@mrbean-bremen
Copy link
Member

Ok, I made a new patch release.

@retr0h
Copy link
Author

retr0h commented Mar 3, 2020

Looks good! Thanks for the quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants