Skip to content

Add function to write header block to .env file#559

Draft
ankona wants to merge 5 commits intotheskumar:mainfrom
ankona:set-header
Draft

Add function to write header block to .env file#559
ankona wants to merge 5 commits intotheskumar:mainfrom
ankona:set-header

Conversation

@ankona
Copy link
Copy Markdown

@ankona ankona commented May 6, 2025

Feature request

Sometimes a user may wish to include a header block in the .env file that is produced. For example, to indicate that the file is automatically generated and updates will not persist:

Sample .env containing header

# This file is automatically generated. Any
# manual changes may be overwritten at any
# time by system XYZ.
a=b
c=d

Proposed Addition

Create a set_header method to write a header block out to the target .env file

Usage

import textwrap
from dotenv import set_header

header = textwrap.dedent(
    """
    # This file is automatically generated. Any
    # manual changes may be overwritten at any
    # time by system XYZ.
    """
)
set_header("~/.env", header)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant