Azure / msrest-for-python

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

Fix unexpected setattr on class attribute if constant #24

Closed lmazuel closed 7 years ago

lmazuel commented 7 years ago

When a constant is used, a class attribute is created by Autorest.

The current msrest has a side effect to add an instance attribute on top of the class attribute on the parameter.

Example, let's says "capacity" is a constant in myobj

# capacity is not in `myobj.__dict__` (class attribute)
client.put_something(myobj)
# capacity IS in `myobj.__dict__` (was copied using setattr)

This breaks the __eq__ contract (based on __dict__)

Thanks to @brettcannon for his help to debug this :)

codecov-io commented 7 years ago

Codecov Report

Merging #24 into master will increase coverage by 0.56%. The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #24      +/-   ##
==========================================
+ Coverage   71.21%   71.77%   +0.56%     
==========================================
  Files           9        9              
  Lines        1188     1201      +13     
==========================================
+ Hits          846      862      +16     
+ Misses        342      339       -3
Impacted Files Coverage Δ
msrest/serialization.py 68.58% <75%> (+0.66%) :arrow_up:
msrest/http_logger.py 79.24% <0%> (+4.82%) :arrow_up:

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 15967ea...0a1d109. Read the comment docs.