Skip to content

[utils] Deprecate make_dir in favor of make_parent_dirs#16931

Merged
bashonly merged 6 commits into
yt-dlp:masterfrom
doe1080:make_dir
Jun 12, 2026
Merged

[utils] Deprecate make_dir in favor of make_parent_dirs#16931
bashonly merged 6 commits into
yt-dlp:masterfrom
doe1080:make_dir

Conversation

@doe1080

@doe1080 doe1080 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Description of your pull request and other information

Fix directory creation error handling

Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check those that apply and remove the others:

What is the purpose of your pull request? Check those that apply and remove the others:

  • Core bug fix/improvement

@doe1080
doe1080 requested review from a team and bashonly June 11, 2026 07:13
@doe1080 doe1080 added the bug Bug that is not site-specific label Jun 11, 2026
@Grub4K

Grub4K commented Jun 11, 2026

Copy link
Copy Markdown
Member

make_dir and its usage is quite bad; for example here the instance gets created but never raised: make_dir(newfile, PostProcessingError)

I think we should actually raise and adjust the call sites accordingly: make_dir should be deprecated and replaced by def makedirs(path: str): which raises:

def make_dir(path, to_screen=None):
    try:
        makedirs(path)
        return True
    except OSError as err:
        if to_screen is not None:
            to_screen(f'unable to create directory {err}')
        return False


def makedirs(path: str):
    dn = os.path.dirname(path)
    if dn:
        os.makedirs(dn, exist_ok=True)

@doe1080

doe1080 commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

makes sense, I'll replace make_dir usages in MoveFilesAfterDownloadPP and _ensure_dir_exists
should make_dir be removed entirely, or kept as a compatibility wrapper?

@doe1080 doe1080 changed the title [utils] make_dir: Fix callable() condition [utils] Migrate make_dir behavior to make_parent_dirs Jun 11, 2026
@doe1080
doe1080 requested a review from Grub4K June 11, 2026 12:44
Comment thread yt_dlp/utils/_utils.py Outdated
@doe1080
doe1080 requested a review from bashonly June 12, 2026 07:56
Comment thread yt_dlp/utils/_deprecated.py Outdated
@doe1080
doe1080 requested a review from bashonly June 12, 2026 10:18
@bashonly bashonly changed the title [utils] Migrate make_dir behavior to make_parent_dirs [utils] Deprecate make_dir in favor of make_parent_dirs Jun 12, 2026
@bashonly
bashonly merged commit b05b408 into yt-dlp:master Jun 12, 2026
21 checks passed
@doe1080
doe1080 deleted the make_dir branch June 13, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug that is not site-specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants