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

Code before:
                   editor_id: Optional[str] = None,
                   timestamp: Optional[datetime] = None,
                   comment: Optional[str] = None,
                   **options: Dict[str, Any]):
        """Creates and adds a new entry in the edits attribute without writing the data.

        Arguments:
            job_id (Optional[str]): The optional identifier of the job writing the data.
            editor_id (Optional[str]): The optional identifier of the editor writing the data.
            timestamp (Optional[datetime]): The optional timestamp of the edit. If not provided, the
                current time is used.
            comment (Optional[str]): The optional comment of the edit.
            options (dict[str, any]): User-custom attributes to attach to the edit.
        """
        edit: Dict[str, Any] = {k: v for k, v in options.items() if v is not None}
        if job_id:
            edit[EDIT_JOB_ID_KEY] = job_id
        if editor_id:
            edit[EDIT_EDITOR_ID_KEY] = editor_id
        if comment:
            edit[EDIT_COMMENT_KEY] = comment
        if not timestamp:
            timestamp = self._get_last_modified_datetime(self._properties.get(self._PATH_KEY)) or datetime.now()
        edit[EDIT_TIMESTAMP_KEY] = timestamp
        self.last_edit_date = edit.get(EDIT_TIMESTAMP_KEY)
        self._edits.append(edit) # type: ignore
        self.edits = self._edits

    def lock_edit(self, editor_id: Optional[str] = None):
        """Lock the data node modification.

        Note:
            The data node can be unlocked with the method `(DataNode.)unlock_edit()^`.

        Arguments:
            editor_id (Optional[str]): The editor's identifier.
        """
        if editor_id:
            if (
                self.edit_in_progress
                and self.editor_id != editor_id
                and self.editor_expiration_date
                and self.editor_expiration_date > datetime.now()
            ):
                raise DataNodeIsBeingEdited(self.id, self._editor_id)
            self.editor_id = editor_id  # type: ignore
            self.editor_expiration_date = datetime.now() + timedelta(minutes=self.__EDIT_TIMEOUT)  # type: ignore
        else:
            self.editor_id = None  # type: ignore
            self.editor_expiration_date = None  # type: ignore
        self.edit_in_progress = True  # type: ignore

Review comment (suggestion):
`type: ignore` should be banned :-)
at least it should give a list of errors `type: ignore[...]`
but a cast would be better ifg t is a cast issue ;-)

Code after:
                   job_id: Optional[str] = None,
                   editor_id: Optional[str] = None,
                   timestamp: Optional[datetime] = None,
                   comment: Optional[str] = None,
                   **options: Any):
        """Creates and adds a new entry in the edits attribute without writing the data.

        Arguments:
            job_id (Optional[str]): The optional identifier of the job writing the data.
            editor_id (Optional[str]): The optional identifier of the editor writing the data.
            timestamp (Optional[datetime]): The optional timestamp of the edit. If not provided, the
                current time is used.
            comment (Optional[str]): The optional comment of the edit.
            **options (Any): User-custom attributes to attach to the edit.
        """
        edit = {k: v for k, v in options.items() if v is not None}
        if job_id:
            edit[EDIT_JOB_ID_KEY] = job_id
        if editor_id:
            edit[EDIT_EDITOR_ID_KEY] = editor_id
        if comment:
            edit[EDIT_COMMENT_KEY] = comment
        if not timestamp:
            timestamp = self._get_last_modified_datetime(self._properties.get(self._PATH_KEY)) or datetime.now()
        edit[EDIT_TIMESTAMP_KEY] = timestamp
        self.last_edit_date = edit.get(EDIT_TIMESTAMP_KEY)
        self._edits.append(typing.cast(Edit, edit))
        self.edits = self._edits

    def lock_edit(self, editor_id: Optional[str] = None):
        """Lock the data node modification.

        Note:
            The data node can be unlocked with the method `(DataNode.)unlock_edit()^`.

        Arguments:
            editor_id (Optional[str]): The editor's identifier.
        """
        if editor_id:
            if (
                self.edit_in_progress
                and self.editor_id != editor_id
                and self.editor_expiration_date
                and self.editor_expiration_date > datetime.now()
            ):
                raise DataNodeIsBeingEdited(self.id, self._editor_id)
            self.editor_id = editor_id  # type: ignore
            self.editor_expiration_date = datetime.now() + timedelta(minutes=self.__EDIT_TIMEOUT)  # type: ignore
        else:
            self.editor_id = None  # type: ignore
            self.editor_expiration_date = None  # type: ignore