# Reduce metaclass conflicts with less eager proclamation, automatic metaclass merges

**URL:** <https://discuss.python.org/t/reduce-metaclass-conflicts-with-less-eager-proclamation-automatic-metaclass-merges/47739>\
**Category:** Ideas\
**Created:** [March 6, 2024, 6:09am UTC](https://discuss.python.org/t/reduce-metaclass-conflicts-with-less-eager-proclamation-automatic-metaclass-merges/47739 "2024-03-06T06:09:05Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![blhsing](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/blhsing/32/25812_2.png) [@blhsing](https://discuss.python.org/u/blhsing)\
**Post date:** [March 12, 2024, 10:14am UTC](https://discuss.python.org/t/reduce-metaclass-conflicts-with-less-eager-proclamation-automatic-metaclass-merges/47739/18 "2024-03-12T10:14:05Z")

</div>

Well I only just noticed that since Python 3.11, there’s this [`slots`](https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass) option built-in to `dataclass` already so at least your specific use case has been taken care of:

```python
from enum import Enum
from dataclasses import dataclass
from typing import Literal

@dataclass(slots=True)
class Card:
    value_: Literal[2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']
    suite: Literal['heart', 'diamond', 'club', 'spade']

class PlayingCards(Card, Enum):
    TWO_OF_HEART = 2, 'heart'
    THREE_OF_SPADES = 3, 'spade'

print(PlayingCards. __slots__ ) # outputs ('value_', 'suite')
PlayingCards.TWO_OF_HEART.value.name = 'foo' # raises AttributeError

```

However, it has to be said that there never was a good reason IMHO for `dataclass` to be a class decorator to begin with if not for fear of a metaclass conflict. People have to use [awkward workarounds](https://stackoverflow.com/questions/61038836/python-dataclass-init-subclass-does-not-load-the-fields-from-subclass) to get ` __init_subclass__ ` to see dataclass fields, for example, only because `dataclass` is a decorator and not a metaclass-driven class.

**Bottom Line**

Reducing metaclass conflicts with a built-in resolution/merging mechanism will encourage developers to make better design choices without fear of affecting user experience.

---

_[View the full topic](https://discuss.python.org/t/reduce-metaclass-conflicts-with-less-eager-proclamation-automatic-metaclass-merges/47739)._
