mikeywaites / kim

Kim: A JSON Serialization and Marshaling framework
http://kim.readthedocs.org/en/latest/
Other
317 stars 17 forks source link

Support for Python 3.7? #176

Closed gantzm closed 6 years ago

gantzm commented 6 years ago

I'm having issues with Python 3.7 and nesting.

When I try and use something like:

environments = field.Collection( field.Nested(EnvironmentMapper) )

I get an error:

{'environments': 'environments not found'}

Any idea where I should look? I tried debugging through the code but couldn't quite grasp where it was failing.

mikeywaites commented 6 years ago

Hey @gantzm

Thanks for getting in touch. So that I can attempt to replicate your issue can you give me a complete test case?

If you're marshaling then some the call with your example data would be useful.

gantzm commented 6 years ago

Hello @mikeywaites

Here is the code needed to demonstrate the exception I'm getting:

https://github.com/GantzGulchInc/PythonKimTest

setup.sh creates the virtualenv and run.sh executes the tests

When I execute this locally this is the output I get:

test1:  [ TestRoot1: {'id': '100002A', 'names': ['name1', 'name2', 'name3']} ]
Test2: An exception occured
Mapping invalid
{'names': 'names not found'}
Traceback (most recent call last):
  File "test.py", line 38, in executeTest2
    root: test2.TestRoot2 = mapper.marshal()
  File "/workspace/projects/GantzGulch/KimBug/venv37/lib/python3.7/site-packages/kim/mapper.py", line 697, in marshal
    raise MappingInvalid(self.errors)
kim.exception.MappingInvalid: Mapping invalid
gantzm commented 6 years ago

@mikeywaites

I must have missed some important parts of the documentation. Turns out if I add the following to the nested field it works:

 names = field.Collection(field.Nested(TestNameMapper2, 
    allow_create = True, 
    allow_updates_in_place = True, 
    allow_partial_updates = True))

The examples in the docs seemed to imply those were automatic, again I should have read all the details. This appears to be working with these options set.

mikeywaites commented 6 years ago

@gantzm Sorry I took a while to reply. I'm pleased you managed to resolve your issue. Perhaps we need to consider making that more explicit in the documentation.

I will also aim to update the test suite to build on python 3.7.

I will close this issue. If you have any other feedback I'm always grateful for it.