Skip to content

[glob] Deprecate glob0 and glob1 functions #14477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

donBarbos
Copy link
Contributor

Source: python/cpython#117371

Warning was added to runtime in 3.13. And I added a check for 3.10 since the root_dir argument appeared only in this version.

This comment has been minimized.

stdlib/glob.pyi Outdated

__all__ = ["escape", "glob", "iglob"]

if sys.version_info >= (3, 13):
__all__ += ["translate"]

def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
if sys.version_info >= (3, 10):
Copy link
Member

@brianschubert brianschubert Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why this is checking for 3.10 instead of 3.13.

I added a check for 3.10 since the root_dir argument appeared only in this version.

Considering that 3.13 > 3.10, I don't see a problem with mentioning a parameter added in 3.10 in a 3.13+ deprecation message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it because these functions are not documented in any case and nowhere in the message is it said from what version they are considered deprecate. As far as I understand, they began to be considered deprecate because the glob() function got the root_dir argument.

The explanation is dubious, but I think we can warn about it from 3.10.
I don't insist on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and another benefit of the >3.10 option - we'll be able to get rid of the if construct earlier

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you mean now. I didn't pick up on the fact that these functions are undocumented, and hence already "deprecated" before 3.13. In that case I don't really have an opinion, either option seems reasonable

Comment on lines +13 to +15
@deprecated("Will be removed in Python 3.15; Use `glob.glob` and pass *root_dir* argument instead.")
def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
@deprecated("Will be removed in Python 3.15; Use `glob.glob` and pass *root_dir* argument instead.")
Copy link
Contributor Author

@donBarbos donBarbos Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general these functions have already been removed from the main branch, so maybe it's worth writing "Removed in ..."?

Suggested change
@deprecated("Will be removed in Python 3.15; Use `glob.glob` and pass *root_dir* argument instead.")
def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
@deprecated("Will be removed in Python 3.15; Use `glob.glob` and pass *root_dir* argument instead.")
@deprecated("Removed in Python 3.15; Use `glob.glob` and pass *root_dir* argument instead.")
def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
@deprecated("Removed in Python 3.15; Use `glob.glob` and pass *root_dir* argument instead.")

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants