Skip to content

Conversation

@ashm-dev
Copy link
Contributor

@ashm-dev ashm-dev commented Nov 14, 2025

Copy link
Contributor

@sharktide sharktide left a comment

Choose a reason for hiding this comment

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

I also don’t think we should restore the cursor position since a file’s line numbers could also change when it is edited and it could cause confusion.

ashm-dev and others added 2 commits November 15, 2025 09:47
Co-authored-by: R.C.M <sharktidedev@gmail.com>
Removed cursor position restoration logic during file reload.
@ashm-dev
Copy link
Contributor Author

I also don’t think we should restore the cursor position since a file’s line numbers could also change when it is edited and it could cause confusion.

Rewrote it, now it won't save cursor position.

@ashm-dev ashm-dev requested a review from sharktide November 15, 2025 07:24
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Please rely more on unittest.mock.patch() as well as mock features directly. In addition add a What's New entry in addition to the NEWS entry.

@bedevere-app
Copy link

bedevere-app bot commented Nov 15, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ashm-dev ashm-dev requested a review from AA-Turner as a code owner November 15, 2025 22:28
@ashm-dev
Copy link
Contributor Author

I have made the requested changes; please review again

Co-authored-by: R.C.M <sharktidedev@gmail.com>
@ashm-dev ashm-dev requested a review from sharktide November 15, 2025 23:03
ashm-dev and others added 2 commits November 16, 2025 02:29
…3.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@picnixz picnixz dismissed their stale review November 15, 2025 23:37

Changes were addressed.

@ashm-dev ashm-dev requested a review from picnixz November 15, 2025 23:53
@sharktide
Copy link
Contributor

You don't need to keep updating the branch because we all get emails and it uses up ci time unless its been really long or unrelated tests fail. When merging, git usually can handle it automatically unless you see that there are conflicts

ashm-dev and others added 2 commits November 19, 2025 09:51
Co-authored-by: R.C.M <sharktidedev@gmail.com>
Co-authored-by: R.C.M <sharktidedev@gmail.com>
@ashm-dev ashm-dev requested a review from sharktide November 19, 2025 06:51
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Please, your PRs always take me long to review because there are unrelated changes, or un-necessary things that are introduced. It's really not the first time. Carefully read the devguide and honestly, avoid using an LLM. If you are worried about NEWS writing, leave it blank and ask someone else to write it for you. But for the code, there are many places where I feel it's been LLM-generated. In general:

  • Never remove code that is not related to the issue you are fixing.
  • Never add type annotations.
  • Never make unrelated changes.
  • Read the devguide.
  • Don't add trivial comments. Usually this is a sign that an LLM has been used.
  • Follow PEP-8. In particular, wrap your code under the 80-char mark.

shelltext = '>>> if 1'
self.editwin.get_prompt_text = Func(result=shelltext)
eq(fix(), shelltext) # Get... call and '\n' not added.
eq(fix(), shelltext) # Get... call and '\n' not added.
Copy link
Member

Choose a reason for hiding this comment

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

Ok, this will be the last time I'm going to say this but please never change unrelated code. Do not use an autoformatter, or configure your IDE so that it doesn't autoformat on save, or ask your LLM not to do any change.

(Contributed by Nick Burns and Senthil Kumaran in :gh:`92936`.)


idlelib
Copy link
Member

Choose a reason for hiding this comment

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

@terryjreedy For IDLE changes, do we add it here or somewhere else in general?

Comment on lines +74 to +79
with patch('idlelib.iomenu.messagebox.showinfo') as mock_showinfo:
result = io.reload(None)
self.assertEqual(result, "break")
mock_showinfo.assert_called_once()
args, kwargs = mock_showinfo.call_args
self.assertIn("File Not Found", args[0])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
with patch('idlelib.iomenu.messagebox.showinfo') as mock_showinfo:
result = io.reload(None)
self.assertEqual(result, "break")
mock_showinfo.assert_called_once()
args, kwargs = mock_showinfo.call_args
self.assertIn("File Not Found", args[0])
with patch('idlelib.iomenu.messagebox.showinfo') as mock_showinfo:
result = io.reload(None)
self.assertEqual(result, "break")
mock_showinfo.assert_called_once()
args, _ = mock_showinfo.call_args
self.assertIn("File Not Found", args[0])

io.loadfile(io.filename)
self.assertEqual(text.get('1.0', 'end-1c'), original_content)

with builtins.open(filename, 'w', encoding='utf-8') as f:
Copy link
Member

Choose a reason for hiding this comment

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

Why using builtins.open now that you have tokenize_open?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure tokenize_open can only open the file in read mode here

Copy link
Member

Choose a reason for hiding this comment

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

It's not about tokenize_open. It's about just using the plain open. There is no need to use builtins.open now that open is not shadowed.

Comment on lines +43 to +48
fd, filename = tempfile.mkstemp(suffix='.py')
os.close(fd)
self.addCleanup(os.unlink, filename)
with builtins.open(filename, 'w', encoding='utf-8') as f:
f.write(content)
return filename
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fd, filename = tempfile.mkstemp(suffix='.py')
os.close(fd)
self.addCleanup(os.unlink, filename)
with builtins.open(filename, 'w', encoding='utf-8') as f:
f.write(content)
return filename
filename = tempfile.mktemp()
self.addCleanup(os_helper.unlink, filename)
with open(filename, "w") as f:
f.write(content)
return filename

We don't care about secure temporary file for a test.

cls.root.destroy()
del cls.root

def _create_tempfile(self, content: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

Don't use type annotations.

text.insert('end', "\n# Unsaved change")
io.set_saved(False)

with patch('idlelib.iomenu.messagebox.askokcancel', return_value=False) as mock_ask:
Copy link
Member

Choose a reason for hiding this comment

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

Please wrap lines under 80 chars.

@bedevere-app
Copy link

bedevere-app bot commented Nov 22, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Copy link
Contributor

@sharktide sharktide left a comment

Choose a reason for hiding this comment

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

Added commit suggestions based on picnixz's comments, also added one suggestion for the news entry

cls.root.destroy()
del cls.root

def _create_tempfile(self, content: str) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def _create_tempfile(self, content: str) -> str:
def _create_tempfile(self, content):

shelltext = '>>> if 1'
self.editwin.get_prompt_text = Func(result=shelltext)
eq(fix(), shelltext) # Get... call and '\n' not added.
eq(fix(), shelltext) # Get... call and '\n' not added.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
eq(fix(), shelltext) # Get... call and '\n' not added.
eq(fix(), shelltext) # Get... call and '\n' not added.

@@ -0,0 +1,3 @@
Add "Reload from Disk" menu item to IDLE's File menu. This allows users to
easily reload a file from disk, discarding any unsaved changes in the editor.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
easily reload a file from disk, discarding any unsaved changes in the editor.
reload a file from disk, discarding unsaved changes in the editor.

Remove unnecessary words

self.text.focus_set()
return "break"

# Reload the file
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Reload the file

Trivial comment

text.insert('end', "\n# Unsaved change")
io.set_saved(False)

with patch('idlelib.iomenu.messagebox.askokcancel', return_value=False) as mock_ask:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
with patch('idlelib.iomenu.messagebox.askokcancel', return_value=False) as mock_ask:
with patch('idlelib.iomenu.messagebox.askokcancel',
return_value=False) as mock_ask:

io.loadfile(io.filename)
self.assertEqual(text.get('1.0', 'end-1c'), original_content)

with builtins.open(filename, 'w', encoding='utf-8') as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure tokenize_open can only open the file in read mode here

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.

3 participants