This is a bit confusing, and not sure it's needed.  ``tmpdir`` is a local variable you're free to use as needed, so this is fine:

            if self.xml_file is None:
                if tmpdir is None:
                    tmpdir = data_dir.get_tmp_dir()
                osfd, xml_file = tempfile.mkstemp(suffix='.xml', dir=tmpdir,
                                              prefix=self.name+'-', text=True)
                self.xml_file = xml_file
                os.close(osfd)