8000 gh-95411: IDLE - Enable using the module browser with .pyw files by erlend-aasland · Pull Request #95397 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

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

Merged
merged 16 commits into from
Jul 30, 2022

Conversation

erlend-aasland
Copy link
Contributor
@erlend-aasland erlend-aasland commented Jul 28, 2022

@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
Copy link
Member
@terryjreedy terryjreedy left a comment

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.

@bedevere-bot
Copy link

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

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

@bedevere-bot
Copy link

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
Copy link
Member
@terryjreedy terryjreedy left a comment

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.

@bedevere-bot
Copy link

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

I have made the requested changes; please review again.

@bedevere-bot
Copy link

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

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

6D40

@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 bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 30, 2022
@bedevere-bot
Copy link

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
0