Giter Site home page Giter Site logo

Comments (7)

rakshith91 avatar rakshith91 commented on July 18, 2024 1

Hi @ludokriss
Can you tell us what version of eventgrid sdk are you using? Also what version of python?

from msrest-for-python.

ludokriss avatar ludokriss commented on July 18, 2024 1

Hey, sorry that I didn't include versions. Here it is, with python 3.7:
azure-eventgrid==1.3.0
msrest==0.6.18

Tested the new SDK so versions:
azure-eventgrid==2.0.0b1
msrest==0.6.19

And the inconsistent behavior is still there. Btw., I like the new sdk 👍

from msrest-for-python.

ludokriss avatar ludokriss commented on July 18, 2024 1

Hey, #224 works perfectly for datetime types, so 👍 on that one. Added a pull request on the #224 PR for decimal types if you want to include that as well

from msrest-for-python.

ludokriss avatar ludokriss commented on July 18, 2024

To follow up with a potential solution to the problem as well, you could implement a change in the current serialize_object to handle more types as it typically ends up here:

def serialize_object(self, attr, **kwargs):
"""Serialize a generic object.
This will be handled as a dictionary. If object passed in is not
a basic type (str, int, float, dict, list) it will simply be
cast to str.
:param dict attr: Object to be serialized.
:rtype: dict or str
"""
if attr is None:
return None
if isinstance(attr, ET.Element):
return attr
obj_type = type(attr)
if obj_type in self.basic_types:
return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs)
if obj_type is _long_type:
return self.serialize_long(attr)
if obj_type is unicode_str:
return self.serialize_unicode(attr)
# If it's a model or I know this dependency, serialize as a Model
elif obj_type in self.dependencies.values() or isinstance(attr, Model):
return self._serialize(attr)
if obj_type == dict:
serialized = {}
for key, value in attr.items():
try:
serialized[self.serialize_unicode(key)] = self.serialize_object(
value, **kwargs)
except ValueError:
serialized[self.serialize_unicode(key)] = None
return serialized
if obj_type == list:
serialized = []
for obj in attr:
try:
serialized.append(self.serialize_object(
obj, **kwargs))
except ValueError:
pass
return serialized
return str(attr)

If you add some more types to this, so that you handle dates by passing datetime types to the date-serializer etc. then you are good.

from msrest-for-python.

lmazuel avatar lmazuel commented on July 18, 2024

Hi @ludokriss
In case you're using an old one, we just released a complete revamping of the SDK as preview:
https://pypi.org/project/azure-eventgrid/2.0.0b1/

from msrest-for-python.

lmazuel avatar lmazuel commented on July 18, 2024

Hi @ludokriss
Got it, may I ask you to provide a data that has all the type you could expect to work by default? You mentionned decimals, but instead of guessing an actual Python code dict would be awesome :).

Note: I'm happy you like this new SDK ;)

from msrest-for-python.

lmazuel avatar lmazuel commented on July 18, 2024

Could you try #224 ?

from msrest-for-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.