Comments (6)
Should the hash take read-only/server generated values into account?
from msrest-for-python.
Currently Ansible is happy without (as you noticed, good catch :)). I have no strong opinion, I think __hash__
does not require unicity (contrary to __eq__
, we can have hash(a) == hash(b)
and a != b
). So this is not a requirement for unicity at least. Is it the good thing? Right now I don't know.
from msrest-for-python.
@brettcannon Opinion on this one?
from msrest-for-python.
Are Models considered immutable? If they aren't then you should not be able to hash them. After that all the details of what you need to do for __hash__
is covered by the docs at https://docs.python.org/3/reference/datamodel.html#object.__hash__ (e.g. if a == b
then hash(a) == hash(b)
).
from msrest-for-python.
@brettcannon It was a note more than deep thought, sorry if I tagged you too ealier before even do some research... So, now I've read your link and the doc 😜
No they aren't immutable. But in most scenario, result from Azure are not changed, so this is interesting. Random ideas:
- How to raise an exception if we used
hash
on the obj, and try to change something inside after that? - - Add a
frozen
method to send a frozen read-only model? @nitzmahone @johanste
from msrest-for-python.
You could also implement something like __getstate__
and return a tuple of immutable values (which you could then substantiate from and also gives you the ability to pickle the class if you want that functionality).
from msrest-for-python.
Related Issues (20)
- Serialization for non-standard types yields incorrect output HOT 7
- "deserialize" from base class Model should have types HOT 1
- If we flatten a constant, it's not getting serialized correctly HOT 1
- Unreachable assertion in test_conf_async_trio_requests HOT 1
- switch ci from travis to GitHub actions HOT 1
- Bug when serializing data with None in header HOT 2
- Incorrect HASH encountered when installing using pip
- Update serializer to honor the null sentinel from azure core
- A warning is logged while using msrest where urllib3 issues: DeprecationWarning: Using 'method_whitelist' with Retry is deprecated and will be removed in v2.0. Use 'allowed_methods' instead
- allow models to deserialize an azure.core.rest.HttpResponse
- Allow using ConsumptionManagementClient as a context manager for HTTPS connections reuse
- [feature] Immutable, hashable models, with text representations
- msrest.serialization.Deserializer.deserialize_object() cannot handle subclasses HOT 2
- This repo is missing important files
- 0.7.0 incompatible with python 3.5? HOT 3
- msrest import error while deploying to azure app HOT 1
- Latest versions (`v0.7.0` and `v0.7.1`) don't have git tags
- versions 3.1.1 through 3.2.1 of oauthlib are vulnerable to CVE-2022-36087
- Serialize np.float64 as float HOT 2
- Question about certifi license compatibility HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msrest-for-python.