It sure does work:

from dataclasses import dataclass

@dataclass
class Test:
    _name: str="schbell"

    @property
    def name(self) -> str:
        return self._name

    @name.setter
    def name(self, v: str) -> None:
        self._name = v

t = Test()
print(t.name) # schbell
t.name = "flirp"
print(t.name) # flirp
print(t) # Test(_name='flirp')

In fact, why should it not? In the end, what you get is just a good old class, derived from type:

print(type(t)) # <class '__main__.Test'>
print(type(Test)) # <class 'type'>

Maybe that's why properties are nowhere mentioned specifically. However, the PEP-557's Abstract mentions the general usability of well-known Python class features:

Because Data Classes use normal class definition syntax, you are free to use inheritance, metaclasses, docstrings, user-defined methods, class factories, and other Python class features.

Answer from shmee on Stack Overflow
🌐
Python
docs.python.org › 3 › library › dataclasses.html
dataclasses — Data Classes
Mutability is a complicated property that depends on the programmer’s intent, the existence and behavior of __eq__(), and the values of the eq and frozen flags in the @dataclass decorator. By default, @dataclass will not implicitly add a __hash__() method unless it is safe to do so. Neither will it add or change an existing explicitly defined __hash__() method. Setting the class attribute __hash__ = None has a specific meaning to Python...
🌐
Florimond Manca
florimond.dev › en › posts › 2018 › 10 › reconciling-dataclasses-and-properties-in-python
Reconciling Dataclasses And Properties In Python - Florimond Manca
In short, dataclasses are a simple, elegant, Pythonic way of creating classes that hold data. 🐍 ... I sometimes resort to the @property decorator to implement specific logic when getting/setting an attribute.
🌐
Medium
medium.com › swlh › python-dataclasses-with-properties-and-pandas-5c59b05e9131
Python Dataclasses With Properties and Pandas | by Sebastian Ahmed | The Startup | Medium
February 21, 2021 - dataclasses provide a very seamless interface to generation of pandas DataFrames. Surprisingly, the construction followed the semantic intent of hidden attributes and pure property-based attributes · More advanced construction of DataFrames may require the use of standard Python classes.
🌐
Python.org
discuss.python.org › python help
Property or Dataclass - Python Help - Discussions on Python.org
January 20, 2024 - Working with an API response, I have 2 possible choices of handling the return and access but I’m lost on which one’s ideal: # Example API Response { 'title': 'Blade Runner', 'year': 1982 } Option 1: property class Movie: def __init__(self, search): self._search = search def api_response(self): response = requests.post(url) @property def title(self) -> str: return response["title"] @property def year(self) -> int: return respo...
🌐
PyPI
pypi.org › project › dataclass-property
dataclass-property
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
GitHub
github.com › florimondmanca › www › issues › 102
Reconciling Dataclasses And Properties In Python · Issue #102 · florimondmanca/www
September 18, 2020 - Reconciling Dataclasses And Properties In Python I love Python dataclasses, but combining them with properties is not obvious. This is a problem solving report — and a practical introduction to dataclasses! https://florimond.dev/blog/art...
Author   utterances-bot
🌐
Dataquest
dataquest.io › blog › how-to-use-python-data-classes
How to Use Python Data Classes (A Beginner's Guide) – Dataquest
May 12, 2025 - If we use the dataclasses module, however, we need to import dataclass to use it as a decorator in the class we're creating. When we do that, we no longer need to write the init function, only specify the attributes of the class and their types.
Find elsewhere
🌐
Better Programming
betterprogramming.pub › how-to-setup-data-classes-in-python-ffd85549523c
How to Setup Data Classes in Python | by Oliver S | Better Programming
November 29, 2022 - The dataclass decorator in Python equips a class with helper functionality around storing data — such as automatically adding a constructor, overloading the __eq__ operator, and the repr function.
🌐
DEV Community
dev.to › florimondmanca › reconciling-dataclasses-and-properties-in-python-4ogc › comments
[Discussion] Reconciling Dataclasses And Properties In Python — DEV Community
from dataclasses import dataclass, field from abc import abstractmethod @dataclass # type: ignore class Vehicle: wheels: int _wheels: int = field(init=False, repr=False) @property def wheels(self) -> int: print('getting wheels') return self._wheels @wheels.setter def wheels(self, wheels: int): print('setting wheels to', wheels) self._wheels = wheels @abstractmethod def sound_horn(self): raise NotImplementedError
🌐
Ritviknag
dcw.ritviknag.com › en › latest › using_field_properties.html
Using Field Properties — Dataclass Wizard 0.39.1 documentation
Using the Annotated type from the typing module (introduced in Python 3.9) it is possible to set a default value for the field property in the annotation itself. This is done by adding a field extra in the Annotated definition as shown below. from dataclasses import dataclass, field from typing import Annotated, Union from dataclass_wizard import property_wizard @dataclass class Vehicle(metaclass=property_wizard): wheels: Annotated[Union[int, str], field(default=4)] # Uncomment the field below if you want to make your IDE a bit happier.
🌐
InfoWorld
infoworld.com › home › software development › programming languages › python
How to use Python dataclasses | InfoWorld
October 22, 2025 - If you have a dataclass Library, with a list property of shelves, you could use a dataclass ReadingRoom to populate that list, then add methods to make it easy to access nested items (e.g., a book on a shelf in a particular room). It’s also important to note, though, that not every Python class needs to be a dataclass.
🌐
Real Python
realpython.com › python-data-classes
Data Classes in Python (Guide) – Real Python
March 8, 2024 - from dataclasses import dataclass from typing import List @dataclass class Deck: # Will NOT work cards: List[PlayingCard] = make_french_deck() Don’t do this! This introduces one of the most common anti-patterns in Python: using mutable default arguments. The problem is that all instances of Deck will use the same list object as the default value of the .cards property...
🌐
DataCamp
campus.datacamp.com › courses › data-types-in-python › advanced-data-types
Dataclasses | Python
Python has a built in decorator called @ property that makes that work as any other property would. Suppose we expand our cookie dataclass to have a new property called cost, a decimal.
🌐
GitHub
github.com › florimondmanca › dataclasses-properties
GitHub - florimondmanca/dataclasses-properties: 🐍🤝 Reconciling Python's dataclasses and properties
This is the supporting repository for "Reconciling Dataclasses And Properties In Python", a blog post published on my blog and (soon) dev.to.
Author   florimondmanca
🌐
Python Tutorial
pythontutorial.net › home › python oop › python dataclass
Python dataclass
November 15, 2021 - The dataclass allows you to define classes with less code and more functionality out of the box. The following defines a regular Person class with two instance attributes name and age: class Person: def __init__(self, name, age): self.name = name self.age = age Code language: Python (python)
🌐
Molssi
education.molssi.org › type-hints-pydantic-tutorial › chapters › DataclassInPython.html
Dataclasses In Python — Python Type Hints, Dataclasses, and Pydantic
Let’s apply that principle to bring back the num_atoms property, and bring our Molecule class to the form we want it in for the end of this chapter. from dataclasses import dataclass from typing import Union @dataclass class Molecule: name: str charge: Union[float, int] symbols: list[str] coordinates: list[list[float]] @property def num_atoms(self): return len(self.symbols) def __str__(self): return f"name: {self.name}\ncharge: {self.charge}\nsymbols: {self.symbols}"
🌐
Python
bugs.python.org › issue39247
Issue 39247: dataclass defaults and property don't work together - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/83428
🌐
GitHub
github.com › python › cpython › issues › 94067
Default value to dataclass field is ignored if setting up getter/setter · Issue #94067 · python/cpython
June 21, 2022 - stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory ... from dataclasses import dataclass, InitVar @dataclass class Test: b: int = 6 id: InitVar[int]=1 def __post_init__(self, id=0): print(f"the value of id is {id} in the post_init") print(f"is id a property: {isinstance(id, property)}") self._id = id @property def id(self): print("using the getter") return self._id @id.setter def id(self, to): print("using the setter") self._id = to print("\nInit with position argument") a = Test(1) print("a is", a) print("a.id is", a.id) print("\nInit with explicit key") a4 = Test(id=4) print("a4.id is", a4.id)
Author   subercui