Azure / msrest-for-python

The runtime library "msrest" for AutoRest generated Python clients.
MIT License
41 stars 64 forks source link

Handle empty enum values #173

Closed annatisch closed 5 years ago

annatisch commented 5 years ago

Fix for logged warnings where service returns an empty (None) value for an enum. These warnings were encountered during header deserialization.

codecov-io commented 5 years ago

Codecov Report

Merging #173 into master will decrease coverage by 0.07%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #173      +/-   ##
==========================================
- Coverage   87.84%   87.77%   -0.08%     
==========================================
  Files          25       25              
  Lines        2584     2584              
==========================================
- Hits         2270     2268       -2     
- Misses        314      316       +2
Impacted Files Coverage Δ
msrest/polling/poller.py 100% <ø> (ø) :arrow_up:
msrest/serialization.py 90.82% <100%> (-0.22%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 91b7392...1a3774d. Read the comment docs.

annatisch commented 5 years ago

Yes there is a change in behaviour, but it's very small and I doubt it will affect any published SDKs. The change is that now missing deserialized enum headers will be None rather than "None".

If we want to preserve absolute behaviour, then this patch could be amended to:

if data is None:
    return str(data)
if isinstance(data, enum_obj):
    return data
# and so on....