[Python-Dev] Is static typing still optional? (original) (raw)

Eric V. Smith eric at trueblade.com
Mon Jan 29 03:57:04 EST 2018


On 1/29/2018 3:42 AM, Ethan Furman wrote:

On 01/28/2018 07:45 AM, Eric V. Smith wrote:

On 1/6/2018 5:13 PM, Eric V. Smith wrote:

On 12/10/2017 5:00 PM, Raymond Hettinger wrote:

2) Change the default value for "hash" from "None" to "False".  This might take a little effort because there is currently an oddity where setting hash=False causes it to be hashable.  I'm pretty sure this wasn't intended ;-)

I haven't looked at this yet. I think the hashing logic explained in https://bugs.python.org/issue32513#msg310830 is correct. It uses hash=None as the default, so that frozen=True objects are hashable In a class, _hash_ = None means the instances are not hashable... but in a dataclass decorator, hash=None means they are?

It means "don't add a hash attribute, and rely on the base class value". But maybe it should mean "is not hashable". But in that case, how would we specify the "don't add hash" case?

Note that "repr=False" means "don't add a repr", not "is not repr-able". And "init=False" means "don't add a init", not "is not init-able".

Eric.



More information about the Python-Dev mailing list