Converts all attributes with callable types to @property methods. This avoids the typechecker getting confused and thinking that `my_dataclass_instance.callable_attr(foo)` is going to receive a `self` argument (it is not).
(
self, attributes: list[DataclassAttribute], settable: bool = True
)
| 775 | info.names[var.name] = SymbolTableNode(MDEF, var) |
| 776 | |
| 777 | def _propertize_callables( |
| 778 | self, attributes: list[DataclassAttribute], settable: bool = True |
| 779 | ) -> None: |
| 780 | """Converts all attributes with callable types to @property methods. |
| 781 | |
| 782 | This avoids the typechecker getting confused and thinking that |
| 783 | `my_dataclass_instance.callable_attr(foo)` is going to receive a |
| 784 | `self` argument (it is not). |
| 785 | |
| 786 | """ |
| 787 | info = self._cls.info |
| 788 | for attr in attributes: |
| 789 | if isinstance(get_proper_type(attr.type), CallableType): |
| 790 | var = attr.to_var(info) |
| 791 | var.info = info |
| 792 | var.is_property = True |
| 793 | var.is_settable_property = settable |
| 794 | var._fullname = info.fullname + "." + var.name |
| 795 | info.names[var.name] = SymbolTableNode(MDEF, var) |
| 796 | |
| 797 | def _is_kw_only_type(self, node: Type | None) -> bool: |
| 798 | """Checks if the type of the node is the KW_ONLY sentinel value.""" |
no test coverage detected