def METHOD_NAME(profiles_dir, dbt_profile_contents):
    def cleanup():
        rm_file(Path(profiles_dir) / "profiles.yml")
    request.addfinalizer(cleanup)
    write_file(yaml.safe_dump(dbt_profile_contents), profiles_dir, "profiles.yml")