We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
With Python 3.11 I get a test failure. All tests pass on Python 3.10.
============================= test session starts ============================== platform linux -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0 rootdir: /build/source collected 237 items tests/test_attrs.py .............. [ 5%] [...] tests/test_specific_versions.py .F........... [ 77%] tests/test_str.py .. [ 78%] tests/test_suppress_warnings.py .. [ 78%] tests/test_time.py .. [ 79%] tests/test_timedelta.py .. [ 80%] tests/test_timezone.py .. [ 81%] tests/test_transform.py .. [ 82%] tests/test_tuple.py ........... [ 86%] tests/test_type_error.py ... [ 88%] tests/test_union.py .......... [ 92%] tests/test_validation.py ....... [ 95%] tests/test_various.py ......... [ 99%] tests/test_verbosity.py . [ 99%] tests/test_version.py . [100%] =================================== FAILURES =================================== ________ TestSpecificVersions.test_dump_load_parameterized_collections _________ json_obj = {'a': 1, 'b': 2} deserializer = <function default_mapping_deserializer at 0x7ffff671f920> cls = dict[str, int], initial = False kwargs = {'_inferred_cls': False, '_initial': False, 'attr_getters': None, 'fork_inst': <class 'jsons._common_impl.StateHolder'>, ...} cls_name = 'dict' message = 'Could not deserialize value "{\'a\': 1, \'b\': 2}" into "dict". isinstance() argument 2 cannot be a parameterized generic' def _do_load(json_obj: object, deserializer: callable, cls: type, initial: bool, **kwargs): cls_name = get_class_name(cls, fully_qualified=True) if deserializer is None: raise DeserializationError('No deserializer for type "{}"'.format(cls_name), json_obj, cls) try: > result = deserializer(json_obj, cls, **kwargs) jsons/_load_impl.py:113: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = {'a': 1, 'b': 2}, cls = dict[str, int] kwargs = {'_inferred_cls': False, '_initial': False, 'attr_getters': None, 'fork_inst': <class 'jsons._common_impl.StateHolder'>, ...} cls_ = typing.Mapping[str, int], cls_args = (<class 'str'>, <class 'int'>) dict_ = {'a': 1, 'b': 2}, result = {'a': 1, 'b': 2} def default_mapping_deserializer(obj: dict, cls: type, **kwargs) -> Mapping: """ Deserialize a (JSON) dict into a mapping by deserializing all items of that dict. :param obj: the dict that needs deserializing. :param cls: the type, optionally with a generic (e.g. Set[str]). :param kwargs: any keyword arguments. :return: a deserialized set instance. """ cls_ = Mapping cls_args = get_args(cls) if cls_args: cls_ = MappingType[cls_args] dict_ = default_dict_deserializer(obj, cls_, **kwargs) result = dict_ # Strip any generics from cls to allow for an instance check. > if not isinstance(result, get_origin(cls)): E TypeError: isinstance() argument 2 cannot be a parameterized generic jsons/deserializers/default_mapping.py:25: TypeError The above exception was the direct cause of the following exception: args = (<tests.test_specific_versions.TestSpecificVersions testMethod=test_dump_load_parameterized_collections>,) kwargs = {} @skipUnless(dont_skip, reason=reason) def _wrapper(*args, **kwargs): > return decorated(*args, **kwargs) tests/test_specific_versions.py:31: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_specific_versions.py:187: in test_dump_load_parameterized_collections loaded = jsons.load(dumped, version_39.C) jsons/_load_impl.py:101: in load return _do_load(json_obj, deserializer, cls, initial, **kwargs_) jsons/_load_impl.py:113: in _do_load result = deserializer(json_obj, cls, **kwargs) jsons/deserializers/default_object.py:40: in default_object_deserializer constructor_args = _get_constructor_args(obj, cls, **kwargs) jsons/deserializers/default_object.py:64: in _get_constructor_args key, value = _get_value_for_attr(obj=obj, jsons/deserializers/default_object.py:94: in _get_value_for_attr result = sig_key, _get_value_from_obj(obj, cls, sig, sig_key, jsons/deserializers/default_object.py:140: in _get_value_from_obj value = load(obj[sig_key], cls_, meta_hints=new_hints, **kwargs) jsons/_load_impl.py:101: in load return _do_load(json_obj, deserializer, cls, initial, **kwargs_) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ json_obj = {'a': 1, 'b': 2} deserializer = <function default_mapping_deserializer at 0x7ffff671f920> cls = dict[str, int], initial = False kwargs = {'_inferred_cls': False, '_initial': False, 'attr_getters': None, 'fork_inst': <class 'jsons._common_impl.StateHolder'>, ...} cls_name = 'dict' message = 'Could not deserialize value "{\'a\': 1, \'b\': 2}" into "dict". isinstance() argument 2 cannot be a parameterized generic' def _do_load(json_obj: object, deserializer: callable, cls: type, initial: bool, **kwargs): cls_name = get_class_name(cls, fully_qualified=True) if deserializer is None: raise DeserializationError('No deserializer for type "{}"'.format(cls_name), json_obj, cls) try: result = deserializer(json_obj, cls, **kwargs) validate(result, cls, kwargs['fork_inst']) except Exception as err: clear() if isinstance(err, JsonsError): raise message = 'Could not deserialize value "{}" into "{}". {}'.format(json_obj, cls_name, err) > raise DeserializationError(message, json_obj, cls) from err E jsons.exceptions.DeserializationError: Could not deserialize value "{'a': 1, 'b': 2}" into "dict". isinstance() argument 2 cannot be a parameterized generic jsons/_load_impl.py:120: DeserializationError =============================== warnings summary =============================== tests/test_datetime.py::TestDatetime::test_dump_datetime_utcnow tests/test_datetime.py::TestDatetime::test_dump_naive_datetime tests/test_object.py::TestObject::test_dump_load_object_deep /build/source/jsons/_common_impl.py:43: UserWarning: The use of datetimes without timezone is dangerous and can lead to [...] =========================== short test summary info ============================ FAILED tests/test_specific_versions.py::TestSpecificVersions::test_dump_load_parameterized_collections - jsons.exceptions.DeserializationError: Could not deserialize value "{'a': 1... ================== 1 failed, 236 passed, 7 warnings in 1.58s ===================
Will become an issue for all distributions with are shipping jsons and are moving to Python 3.11. For nixpkgs I'm disabling that test for now.
jsons
The text was updated successfully, but these errors were encountered:
I get this error in 3.12 in a project, is there any fix available?
Sorry, something went wrong.
No branches or pull requests
With Python 3.11 I get a test failure. All tests pass on Python 3.10.
Will become an issue for all distributions with are shipping
jsons
and are moving to Python 3.11. For nixpkgs I'm disabling that test for now.The text was updated successfully, but these errors were encountered: