python-jsonschema / jsonschema

An implementation of the JSON Schema specification for Python
https://python-jsonschema.readthedocs.io
MIT License
4.63k stars 581 forks source link

Deprecation warning, affects compatibility with Python 3.8 #487

Closed jasonrhaas closed 6 years ago

jasonrhaas commented 6 years ago

When running tests with pytest, I noticed some deprecation warnings popping up. It appears that starting in Python 3.8 we will start to see some issues.

/python3.7/site-packages/jsonschema/compat.py:6:
DeprecationWarning: Using or importing the ABCs from 'collections' instead of 
from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import MutableMapping, Sequence  # noqa
Julian commented 6 years ago

Hey. Pretty sure someone sent a patch to fix this on HEAD, what version are you on?

Julian commented 6 years ago

Of jsonschema I mean.

jasonrhaas commented 6 years ago

I'm running:

jsonschema==2.6.0

So the fix is in the alpha release?

Julian commented 6 years ago

Should be yeah

On Nov 8, 2018 14:15, "Jason Haas" notifications@github.com wrote:

I'm running:

jsonschema==2.6.0

So the fix is in the alpha release?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Julian/jsonschema/issues/487#issuecomment-437121523, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUIXiBXnVv8WqpDqJXtR0ou_mfrBdFiks5utILdgaJpZM4YU-AF .

Julian commented 6 years ago

Closing, but let me know if that's not the case.

kazz-s commented 5 years ago

your problem is that you got 2 import mixed up

import operator
import sys

try:
    from collections import MutableMapping, Sequence  # noqa
except ImportError:
    from collections.abc import MutableMapping, Sequence  # noqa

you should use from collections.abc ... by default and then on error fall back to from collections ....

While from collections import MutableMapping works we will keep getting this warning.

lifeeric commented 2 years ago

Hey all, I still have this problem while testing with pytest. don't know what's causing it.

JsonSchema:

jsonschema==2.6.0
    # via flasgger
env/lib/python3.9/site-packages/jsonschema/compat.py:6
env/lib/python3.9/site-packages/jsonschema/compat.py:6
  /env/lib/python3.9/site-packages/jsonschema/compat.py:6: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    from collections import MutableMapping, Sequence  # noqa

thank you all!

Julian commented 2 years ago

Hi there, sounds like that belongs filed on flasgger, that's a very old version of this library that's being depended on.

lifeeric commented 2 years ago

@Julian when I only import from from collections.abc on compay.py then the warning disappears:

from collections.abc import MutableMapping, Sequence  # noqa

instead of :

try:
    from collections import MutableMapping, Sequence  # noqa
except ImportError:
    from collections.abc import MutableMapping, Sequence  # noqa
Julian commented 2 years ago

That code isn't present on any recent version of this library.