@logfile.setter
def logfile(self, logfile: Union[(str, Path, TextIO, None)]):
    if ((not hasattr(logfile, 'write')) and logfile):
        self.logpath = logfile
    else:
        if (not logfile):
            logfile = (sys.stdout if self._is_run_from_ipython() else sys.stderr)
        self._logfile = logfile
        self._logpath = None
        _set_log_file(self)
@logfile.setter
def logfile(self, logfile: Union[(str, Path, TextIO, None)]):
    if ((not hasattr(logfile, 'write')) and logfile):
        self.logpath = logfile
    else:
        if (not logfile):
            logfile = (sys.stdout if self._is_run_from_ipython() else sys.stderr)
        self._logfile = logfile
        self._logpath = None
        _set_log_file(self)