Skip to content

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

Merged
terryjreedy merged 16 commits into
python:mainfrom
erlend-aasland:idle/dont-hardcode-extensions
Jul 30, 2022
Merged

terryjreedy merged 16 commits into
python:mainfrom
erlend-aasland:idle/dont-hardcode-extensions

Conversation

@erlend-aasland

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

Copy link
Copy Markdown
Contributor

Comment thread Lib/idlelib/util.py Outdated
@erlend-aasland
erlend-aasland requested a review from merwok July 28, 2022 18:40
@merwok
merwok removed their request for review July 28, 2022 18:50
@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

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread Lib/idlelib/idle_test/test_util.py Outdated
@bedevere-bot

Copy link
Copy Markdown

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

erlend-aasland commented Jul 29, 2022 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

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

@bedevere-bot

Copy link
Copy Markdown

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 July 29, 2022 09:05
@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

@terryjreedy terryjreedy left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment thread Misc/NEWS.d/next/IDLE/2022-07-29-11-08-52.gh-issue-95411.dazlqH.rst Outdated
Comment thread Lib/idlelib/NEWS.txt Outdated
@bedevere-bot

Copy link
Copy Markdown

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

@erlend-aasland

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot

Copy link
Copy Markdown

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 July 29, 2022 18:43
@terryjreedy
terryjreedy merged commit 7e19e41 into python:main Jul 30, 2022
@miss-islington

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 30, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request 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 pull request 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
Copy Markdown

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

miss-islington added a commit that referenced this pull request 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 pull request 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 July 30, 2022 05:45
@AlexWaygood
AlexWaygood removed their request for review August 4, 2022 12:30
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.

6 participants