Skip to content
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

gh-95411: IDLE - Enable using the module browser with .pyw files #95397

Merged
merged 16 commits into from Jul 30, 2022

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Jul 28, 2022

Lib/idlelib/util.py Outdated Show resolved Hide resolved
@erlend-aasland erlend-aasland requested a review from merwok Jul 28, 2022
@merwok merwok removed their request for review Jul 28, 2022
@terryjreedy terryjreedy changed the title gh-89610: Don't hardcode supported extensions in IDLE browser gh-95411: Don't hardcode supported extensions in IDLE browser Jul 29, 2022
Copy link
Member

@terryjreedy terryjreedy left a comment

For me on main, .pyw can be browsed, .pyi cannot. I am not surprised because .pyi files cannot be imported and it could be said that they are not modules. In any case, pyclbr use importlib in spec = importlib.util._find_spec_from_path(fullmodule, search_path) and calls
spec.submodule_search_locations and spec.loader.get_source. We might have to continue to exclude .pyi files.

Lib/idlelib/idle_test/test_util.py Outdated Show resolved Hide resolved
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 29, 2022

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

- use util.py_extensions in test
- remove now obsoleted UtilTest.test_extensions
@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Jul 29, 2022

I am not surprised because .pyi files cannot be imported and it could be said that they are not modules.
In any case, pyclbr use importlib in spec = importlib.util._find_spec_from_path(fullmodule, search_path) and calls
spec.submodule_search_locations and spec.loader.get_source. We might have to continue to exclude .pyi files.

The pyclbr module; TIL.

Anyway, I agree with this. That makes this PR moot, though. We can close it together with the linked PR.

One possibility is to use two sets:

  • supported importable extensions
  • supported highlightable extensions (extending the former)

Another solution: add more data to the set and couple it with e.g. is_browseable_extension helper

py_extensions = (
    # (ext, browseable)
    (".py", True),
    (".pyw", True),
    (".pyi", False),
)
# possible enhancement: use namedtuple iso. ordinary tuple

Third, and simplest solution: add a new can_browse_extension (or is_browseable_extension) helper that explicitly excludes .pyi.

@erlend-aasland erlend-aasland added pending The issue will be closed if no feedback is provided and removed pending The issue will be closed if no feedback is provided labels Jul 29, 2022
@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Jul 29, 2022

I believe I have made the requested changes; please review again.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 29, 2022

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from terryjreedy Jul 29, 2022
@terryjreedy terryjreedy changed the title gh-95411: Don't hardcode supported extensions in IDLE browser gh-95411: IDLE - Enable using the module browser with .pyw files Jul 29, 2022
Copy link
Member

@terryjreedy terryjreedy left a comment

Pending a last look, I expect to merge after you move the browser stuff as requested above.

Lib/idlelib/NEWS.txt Outdated Show resolved Hide resolved
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 29, 2022

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Jul 29, 2022

I have made the requested changes; please review again.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 29, 2022

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from terryjreedy Jul 29, 2022
@terryjreedy terryjreedy merged commit 7e19e41 into python:main Jul 30, 2022
14 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 30, 2022

Thanks @erlend-aasland for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒🤖

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 30, 2022

GH-95457 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 30, 2022
pythonGH-95397)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 7e19e41)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 30, 2022
pythonGH-95397)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 7e19e41)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 30, 2022

GH-95458 is a backport of this pull request to the 3.10 branch.

miss-islington added a commit that referenced this issue Jul 30, 2022
…95397)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 7e19e41)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
miss-islington added a commit that referenced this issue Jul 30, 2022
…95397)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 7e19e41)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
@erlend-aasland erlend-aasland deleted the idle/dont-hardcode-extensions branch Jul 30, 2022
@AlexWaygood AlexWaygood removed their request for review Aug 4, 2022
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.

None yet

6 participants