Repository: Avaiga/taipy
File: taipy/core/data/data_node.py (Python)

Code before:

        Returns:
            The data referenced by this data node.

        Raises:
            NoData^: If the data has not been written yet.
        """
        if not self.last_edit_date:
            raise NoData(f"Data node {self.id} from config {self.config_id} has not been written yet.")
        return self._read()

    def read(self) -> Any:
        """Read the data referenced by this data node.

        Returns:
            The data referenced by this data node. None if the data has not been written yet.
        """
        try:
            return self.read_or_raise()
        except NoData:
            self._logger.warning(
                f"Data node {self.id} from config {self.config_id} is being read but has never been written."
            )
            return None

    def append(self, data, editor_id: Optional[str] = None, **kwargs: Dict[str, Any]):
        """Append some data to this data node.

        Arguments:
            data (Any): The data to write to this data node.
            editor_id (str): An optional identifier of the editor.
            **kwargs (dict[str, any]): Extra information to attach to the edit document
                corresponding to this write.
        """
        from ._data_manager_factory import _DataManagerFactory

        self._append(data)
        self.track_edit(editor_id=editor_id, **kwargs)
        self.unlock_edit()
        _DataManagerFactory._build_manager()._set(self)

    def write(self, data, job_id: Optional[JobId] = None, **kwargs: Dict[str, Any]):
        """Write some data to this data node.

        Arguments:
            data (Any): The data to write to this data node.
            job_id (JobId): An optional identifier of the job writing the data.
            **kwargs (dict[str, any]): Extra information to attach to the edit document
                corresponding to this write.
        """
        from ._data_manager_factory import _DataManagerFactory

Review comment (bug):
kwargs shouldn't be typed like this, more like `**kwargs: Any`
https://stackoverflow.com/questions/37031928/type-annotations-for-args-and-kwargs

Code after:
        """Read the data referenced by this data node.

        Returns:
            The data referenced by this data node.

        Raises:
            NoData^: If the data has not been written yet.
        """
        if not self.last_edit_date:
            raise NoData(f"Data node {self.id} from config {self.config_id} has not been written yet.")
        return self._read()

    def read(self) -> Any:
        """Read the data referenced by this data node.

        Returns:
            The data referenced by this data node. None if the data has not been written yet.
        """
        try:
            return self.read_or_raise()
        except NoData:
            self._logger.warning(
                f"Data node {self.id} from config {self.config_id} is being read but has never been written."
            )
            return None

    def append(self, data, editor_id: Optional[str] = None, **kwargs: Any):
        """Append some data to this data node.

        Arguments:
            data (Any): The data to write to this data node.
            editor_id (str): An optional identifier of the editor.
            **kwargs (Any): Extra information to attach to the edit document
                corresponding to this write.
        """
        from ._data_manager_factory import _DataManagerFactory

        self._append(data)
        self.track_edit(editor_id=editor_id, **kwargs)
        self.unlock_edit()
        _DataManagerFactory._build_manager()._set(self)

    def write(self, data, job_id: Optional[JobId] = None, **kwargs: Any):
        """Write some data to this data node.

        Arguments:
            data (Any): The data to write to this data node.
            job_id (JobId): An optional identifier of the job writing the data.
            **kwargs (Any): Extra information to attach to the edit document
                corresponding to this write.
        """