msg403738 - (view) |
Author: Alex Waygood (AlexWaygood) * |
Date: 2021-10-12 15:24 |
IDLE currently does not do any syntax highlighting if you use it to open a .pyi stub file, even though everything in a .pyi file is a valid Python expression. It would be great if syntax highlighting for .pyi files could be supported.
|
msg403741 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2021-10-12 15:51 |
It should be fairly easy to recognize x.pyi as a python file. Just have to find the place. Something like
def f(i:int) -> int: ...
would have 'def' and 'int' highlighted.
|
msg403755 - (view) |
Author: Alex Waygood (AlexWaygood) * |
Date: 2021-10-12 19:36 |
It looks like support for .py files is hardcoded into IDLE's source code in the following places:
* browser.ModuleBrowserTreeItem.OnDoubleClick
* browser.ModuleBrowserTreeItem.IsExpandable
* browser.ModuleBrowserTreeItem.listchildren
* editor.ispythonsource << This is the one that controls syntax highlighting
* iomenu.IOBinding.filetypes
If I were to file a PR adding support for .pyi files, would you prefer that I hardcoded ".pyi" in, or would it be better to add a SUPPORTED_FILES constant somewhere?
|
msg403772 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2021-10-13 00:49 |
Thank you for doing the research.
I have been thinking about adding a file containing idlelib 'leaf' objects, those with no idlelib dependencies, which are needed in more than one file. would be to reduce the complexity of the idlelib dependency graph, which has enough cyclic dependencies to make startup tricky. Time to do it. idlelib/common.py?, leaves.py?, or ??? Draft:
---
"""Idlelib objects with no external idlelib dependencies and which are needed in more than one idlelib module. They are included here because a) they don't particularly belong elsewhere or b) because inclusion here simplifies the idlelib dependency graph.
TODO: Python versions (editor and help_about), tk version and patchlevel (pyshell, help_about, maxos?, editor?), std streams (pyshell, run), warning stuff (ditto).
"""
# python_extensions is used in editor, browser, and iomenu.
# .pyw is for Windows; .pyi is for stub files.
python_extensions = ('.py', '.pyw', '.pyi')
extension_string = "*" + " *".join(python_extensions)
---
editor.EditorWindow.ispythonsource could be moved into the new file if a 'firstline=None' argument were added.
OnDoubleClick should use IsExpandable. IsExpandable should use the logic in ispythonsource so Linux no-extension python source can be browsed as well as edited.
After manual testing, add a new test_common.py file in idlelib.idle_test. After imports, it could start with one test:
class ExtensionTest(TestCase):
def test_stub(self):
self.assertIn('.pyi', common.python_extensions)
self.assertIn('.pyi', common.extension_string)
For IDLE, I can and will backport.
|
msg403884 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2021-10-14 03:27 |
I am going to call the file util.py and will work on a PR.
|
msg403889 - (view) |
Author: Alex Waygood (AlexWaygood) * |
Date: 2021-10-14 07:36 |
Oh — I've already nearly finished a PR. Do you mind if I submit mine? Happy to make any changes you like, obviously.
|
msg403915 - (view) |
Author: Alex Waygood (AlexWaygood) * |
Date: 2021-10-14 16:25 |
Have posted my PR. I've tested it manually and run the IDLE test suite on it with the `-u all` setting; it seems fine. The new tests I've written are a bit thin on the ground right now, though. I may need some guidance/help if more extensive tests are needed -- I'm a little new to unittest.
One other thing I'm not sure on: the docstring at the top of `browser.py` includes the line "- finish removing limitation to x.py files (ModuleBrowserTreeItem)" in the TODO items. Can this be removed now?
|
msg403998 - (view) |
Author: E. Paine (epaine) * |
Date: 2021-10-15 09:58 |
Would it make sense, since this issue pretty much makes IDLE officially support .pyi files, to add the "Edit with IDLE" menu when right-clicking on a .pyi file in Windows explorer?
|
msg404021 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2021-10-15 14:15 |
Yes. After this issue is done, we should open a new issue and nosy Steve Dower, who is in charge of that for Windows, and Ned Deily, in case anything should be done on mac.
|
msg404023 - (view) |
Author: Ronald Oussoren (ronaldoussoren) * |
Date: 2021-10-15 14:23 |
The most straightforward change for macOS is to add “pyi” to the list of extensions in “Mac/IDLE/IDLE.app/Contents/Info.plist”. That way IDLE will be seen as a valid editor for .pyi files.
|
msg404030 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2021-10-15 15:29 |
Steve, how do we make it so that "Edit with IDLE" appears when right-clicking on a .pyi file in Windows explorer? As easy as on mac (see Ronald's answer above)?
|
msg404100 - (view) |
Author: Steve Dower (steve.dower) * |
Date: 2021-10-16 16:34 |
Bit more complicated. It'll need changes to Tools/msi/launcher/launcher_reg.wxs, Tools/msi/tcltk/tcltk_reg.wxs, and PC/layout/support/appxmanifest.py, but I don't think it's that obvious where (we don't want these files to open with py.exe by default, so they'll need a whole new definition).
|
msg404102 - (view) |
Author: Alex Waygood (AlexWaygood) * |
Date: 2021-10-16 16:54 |
Shall I add the change to the mac file to my PR, or would it be better to leave it for a separate PR? (I'm not confident enough to make the changes to the Windows files.)
|
msg404110 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2021-10-16 19:11 |
We can add the mac change once it is manually tested on some system. I may try on my macbook. Windows will be another PR or even issue.
|
msg410637 - (view) |
Author: Alex Waygood (AlexWaygood) * |
Date: 2022-01-15 10:14 |
@terry, have you had a chance to glance at my PR at all? I'd really appreciate your review! :)
|
msg410669 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-01-16 03:41 |
A minimal version of util.py just for this issue is fine. What is blocking the issue deciding exactly what the minimum should be. Are both the extension list and function needed?
Alex says somewhere in PR comments that ispythonsource passes directories. That seems wrong. Perhaps moving and revising it and making no-extension files browsable and removing the x.py(?) limitation should be a separate issue. IDLE users on *nix don't mind using extensions. I have not seen a complaint, though perhaps people who do mind silently use something else. I need to check again how the editor function is used and decide if we can leave it alone for now. So don't remove anything just now.
I need to experiment with Ron's suggestion on my Mac.
The Windows context menu is definitely a separate issue.
Please add idle_test/example.pyi with the line in msg403741 for manual testing now and possibly future automatic testing.
|
msg412561 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-02-05 05:14 |
For the open dialog, we only need the expanded extension list. People with no-extension python code file must select 'all files'. Once the file is open, we need the issource function to decide whether to turn on the colorizer. I intend to review the patch itself tomorrow.
|
msg412617 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-02-06 06:39 |
I broaden the issue title scope and will correspondingly restrict the PR scope. 'Recognition' applies to open and save dialogs, syntax marking, and module browsing. (The latter needs fixing for .pyw also.)
Improving the handling of no extension source with initial #! line will be a different issue.
|
msg413147 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-02-13 00:04 |
New changeset 50cf4991c49e19f917305dd7b9c71085c11edddb by Alex Waygood in branch 'main':
bpo-45447: Add syntax highlighting for `.pyi` files in IDLE (GH-28950)
https://github.com/python/cpython/commit/50cf4991c49e19f917305dd7b9c71085c11edddb
|
msg413149 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-02-13 00:52 |
New changeset 9fabcfbe68ff81ef5f17f86a93daf9cce9d83876 by Terry Jan Reedy in branch '3.10':
bpo-45447: Add syntax highlighting for `.pyi` files in IDLE (GH-28950)
https://github.com/python/cpython/commit/9fabcfbe68ff81ef5f17f86a93daf9cce9d83876
|
msg413150 - (view) |
Author: miss-islington (miss-islington) |
Date: 2022-02-13 01:19 |
New changeset 1d4d44c385414042cbdd2a1e9504cd8e9d69c0ae by Miss Islington (bot) in branch '3.9':
bpo-45447: Add syntax highlighting for `.pyi` files in IDLE (GH-28950)
https://github.com/python/cpython/commit/1d4d44c385414042cbdd2a1e9504cd8e9d69c0ae
|
msg413156 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-02-13 02:10 |
New changeset 2d98433549be358d1c192e30e51b8d345d618cc7 by Terry Jan Reedy in branch 'main':
bpo-45447: Add entry to What's new 3.10 (GH-31304)
https://github.com/python/cpython/commit/2d98433549be358d1c192e30e51b8d345d618cc7
|
msg413157 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-02-13 02:11 |
New changeset cef91ca80c41749824eca1d4b2c99731e3d5f64c by Terry Jan Reedy in branch 'main':
bpo-45447: Add entry to What's new 3.9 (GH-31305)
https://github.com/python/cpython/commit/cef91ca80c41749824eca1d4b2c99731e3d5f64c
|
msg413158 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-02-13 02:12 |
New changeset 6331c08d1c3248ff47a7b8e0045c9023c9af672c by Terry Jan Reedy in branch 'main':
bpo-45447: Fix entry in What's New 3.11 (GH-31307)
https://github.com/python/cpython/commit/6331c08d1c3248ff47a7b8e0045c9023c9af672c
|
msg413168 - (view) |
Author: miss-islington (miss-islington) |
Date: 2022-02-13 06:30 |
New changeset 5698e0be8e77bd4d7a1fda88005662f0b239dec8 by Miss Islington (bot) in branch '3.10':
bpo-45447: Add entry to What's new 3.9 (GH-31305)
https://github.com/python/cpython/commit/5698e0be8e77bd4d7a1fda88005662f0b239dec8
|
msg413169 - (view) |
Author: miss-islington (miss-islington) |
Date: 2022-02-13 06:30 |
New changeset ebe73e6095fc019fd1e31c9f41bc67d56ee003b6 by Miss Islington (bot) in branch '3.9':
bpo-45447: Add entry to What's new 3.9 (GH-31305)
https://github.com/python/cpython/commit/ebe73e6095fc019fd1e31c9f41bc67d56ee003b6
|
msg413170 - (view) |
Author: miss-islington (miss-islington) |
Date: 2022-02-13 06:31 |
New changeset 44666c3285a52c2a4632f89aeeddd7ca7d02c8df by Miss Islington (bot) in branch '3.10':
bpo-45447: Add entry to What's new 3.10 (GH-31304)
https://github.com/python/cpython/commit/44666c3285a52c2a4632f89aeeddd7ca7d02c8df
|
msg413211 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2022-02-14 03:35 |
Issue 46746 is the followup for browsers (currently restricted to .py files) and anything else.
|
|
Date |
User |
Action |
Args |
2022-04-11 14:59:51 | admin | set | github: 89610 |
2022-02-14 03:35:10 | terry.reedy | set | messages:
+ msg413211 title: Make IDLE recognize .pyi stub files (and .pyw) as python source -> Make IDLE recognize .pyi stub files as source for open, save, and edit |
2022-02-13 06:31:10 | miss-islington | set | messages:
+ msg413170 |
2022-02-13 06:30:39 | miss-islington | set | messages:
+ msg413169 |
2022-02-13 06:30:34 | miss-islington | set | messages:
+ msg413168 |
2022-02-13 02:12:25 | terry.reedy | set | messages:
+ msg413158 |
2022-02-13 02:11:33 | miss-islington | set | pull_requests:
+ pull_request29471 |
2022-02-13 02:11:29 | miss-islington | set | pull_requests:
+ pull_request29470 |
2022-02-13 02:11:24 | terry.reedy | set | messages:
+ msg413157 |
2022-02-13 02:10:49 | terry.reedy | set | messages:
+ msg413156 |
2022-02-13 02:10:41 | miss-islington | set | pull_requests:
+ pull_request29469 |
2022-02-13 01:19:32 | miss-islington | set | messages:
+ msg413150 |
2022-02-13 00:59:34 | terry.reedy | set | pull_requests:
+ pull_request29468 |
2022-02-13 00:52:47 | miss-islington | set | nosy:
+ miss-islington pull_requests:
+ pull_request29467
|
2022-02-13 00:52:45 | terry.reedy | set | messages:
+ msg413149 |
2022-02-13 00:51:52 | terry.reedy | set | pull_requests:
+ pull_request29466 |
2022-02-13 00:47:26 | terry.reedy | set | pull_requests:
+ pull_request29465 |
2022-02-13 00:25:08 | terry.reedy | set | pull_requests:
+ pull_request29464 |
2022-02-13 00:04:56 | terry.reedy | set | messages:
+ msg413147 |
2022-02-06 06:39:12 | terry.reedy | set | messages:
+ msg412617 title: IDLE: Support syntax highlighting for .pyi stub files -> Make IDLE recognize .pyi stub files (and .pyw) as python source |
2022-02-05 05:14:55 | terry.reedy | set | messages:
+ msg412561 |
2022-01-16 03:41:00 | terry.reedy | set | messages:
+ msg410669 |
2022-01-15 10:14:23 | AlexWaygood | set | messages:
+ msg410637 |
2021-10-16 19:11:57 | terry.reedy | set | messages:
+ msg404110 |
2021-10-16 16:54:34 | AlexWaygood | set | messages:
+ msg404102 |
2021-10-16 16:34:21 | steve.dower | set | messages:
+ msg404100 |
2021-10-15 15:29:47 | terry.reedy | set | nosy:
+ steve.dower messages:
+ msg404030
|
2021-10-15 14:23:10 | ronaldoussoren | set | nosy:
+ ronaldoussoren messages:
+ msg404023
|
2021-10-15 14:15:21 | terry.reedy | set | messages:
+ msg404021 |
2021-10-15 09:58:47 | epaine | set | messages:
+ msg403998 |
2021-10-14 16:25:24 | AlexWaygood | set | messages:
+ msg403915 |
2021-10-14 16:10:50 | AlexWaygood | set | keywords:
+ patch stage: test needed -> patch review pull_requests:
+ pull_request27239 |
2021-10-14 11:12:26 | epaine | set | nosy:
+ epaine
|
2021-10-14 07:36:51 | AlexWaygood | set | messages:
+ msg403889 |
2021-10-14 03:27:13 | terry.reedy | set | messages:
+ msg403884 |
2021-10-13 00:49:08 | terry.reedy | set | messages:
+ msg403772 stage: test needed |
2021-10-12 19:36:00 | AlexWaygood | set | messages:
+ msg403755 |
2021-10-12 15:51:22 | terry.reedy | set | messages:
+ msg403741 |
2021-10-12 15:24:54 | AlexWaygood | set | title: Support syntax highlighting for .pyi stub files -> IDLE: Support syntax highlighting for .pyi stub files |
2021-10-12 15:24:36 | AlexWaygood | create | |