FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-104719: Restore Tokenize module constants by mgmacias95 · Pull Request #104722 · python/cpython · GitHub

/ cpython Public

gh-104719: Restore Tokenize module constants - #104722

Merged
pablogsal merged 1 commit into
python:mainfrom
mgmacias95:restore_tokenize
May 21, 2023
Merged

gh-104719: Restore Tokenize module constants#104722
pablogsal merged 1 commit into
python:mainfrom
mgmacias95:restore_tokenize

Conversation

mgmacias95 commented May 21, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

I was wondering if you could do something like this:

_deprecated_objects = {
    "group": lambda *choices: '(' + '|'.join(choices) + ')',
    "any": lambda *choices: group(*choices) + '*',
    "maybe": lambda *choices: group(*choices) + '?',
    "Whitespace": r'[ \f\t]*',
    # etc.
}

And then at the end of the file have:

def __getattr__(name):
    if name in _deprecated_objects:
        import warnings
        warnings._deprecated(
            f"tokenize.{name}",
            message=(
                "{name} is untested, undocumented, and deprecated. "
                "It will be removed in Python {remove}."
            ),
            remove=(3, 14)
        )
        obj = globals()[name] = _deprecated_objects[name]
        return obj
    raise AttributeError(f"module 'tokenize' has no attribute '{name}'")

But I will defer to you and @pablogsal as to whether that's a good idea or not.

Copy link
Copy Markdown
Member

Looks like this does fix the immediate issue, though -- IDLE is once again able to open .py files 🎉

pablogsal commented May 21, 2023
edited
Loading

Copy link
Copy Markdown
Member

But I will defer to you and @pablogsal as to whether that's a good idea or not.

For the time being, let's just scope this PR to restoring the constants and let's keep the discussion open in the main issue. Also, let's wait until @Yhg1s mentions what he would prefer. Among other things I can imagine an outcome when we promote these to public interface.

Copy link
Copy Markdown
Member

For the time being, let's just scope this PR to restoring the constants and let's keep the discussion open in the main issue. Also, let's wait until @Yhg1s mentions what he would prefer. Among other things I can imagine an outcome when we promote these to public interface.

SGTM.

mgmacias95 deleted the restore_tokenize branch May 21, 2023 16:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL