From ed7513918424845a9deba93224adc105a820e80b Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 04:03:20 +0400 Subject: [PATCH 01/14] Update imports --- Lib/_pyrepl/_threading_handler.py | 2 +- Lib/_pyrepl/commands.py | 5 +++-- Lib/_pyrepl/completing_reader.py | 14 +++++++------- Lib/_pyrepl/historical_reader.py | 4 +++- Lib/_pyrepl/input.py | 5 +++-- Lib/_pyrepl/pager.py | 4 ++-- Lib/_pyrepl/reader.py | 7 +++++-- Lib/_pyrepl/readline.py | 19 +++++++------------ Lib/_pyrepl/simple_interact.py | 12 +++++------- Lib/_pyrepl/trace.py | 5 +++-- Lib/_pyrepl/unix_console.py | 2 -- Lib/_pyrepl/windows_console.py | 11 +++++------ 12 files changed, 44 insertions(+), 46 deletions(-) diff --git a/Lib/_pyrepl/_threading_handler.py b/Lib/_pyrepl/_threading_handler.py index 82f5e8650a2072..67794d62f16136 100644 --- a/Lib/_pyrepl/_threading_handler.py +++ b/Lib/_pyrepl/_threading_handler.py @@ -3,8 +3,8 @@ from dataclasses import dataclass, field import traceback - TYPE_CHECKING = False + if TYPE_CHECKING: from threading import Thread from types import TracebackType diff --git a/Lib/_pyrepl/commands.py b/Lib/_pyrepl/commands.py index 503ca1da329eaa..9bd3af33c522a5 100644 --- a/Lib/_pyrepl/commands.py +++ b/Lib/_pyrepl/commands.py @@ -32,8 +32,9 @@ # [completion] -# types -if False: +TYPE_CHECKING = False + +if TYPE_CHECKING: from .historical_reader import HistoricalReader diff --git a/Lib/_pyrepl/completing_reader.py b/Lib/_pyrepl/completing_reader.py index 1cd4b6367ca8b1..79b0b2914ab7cc 100644 --- a/Lib/_pyrepl/completing_reader.py +++ b/Lib/_pyrepl/completing_reader.py @@ -23,13 +23,13 @@ from dataclasses import dataclass, field import re -from . import commands, console, reader -from .reader import Reader +from . import commands, console +from .reader import Reader, SYNTAX_WORD -# types -Command = commands.Command -if False: +TYPE_CHECKING = False + +if TYPE_CHECKING: from .types import KeySpec, CommandName @@ -252,7 +252,7 @@ def collect_keymap(self) -> tuple[tuple[KeySpec, CommandName], ...]: return super().collect_keymap() + ( (r'\t', 'complete'),) - def after_command(self, cmd: Command) -> None: + def after_command(self, cmd: commands.Command) -> None: super().after_command(cmd) if not isinstance(cmd, (complete, self_insert)): self.cmpltn_reset() @@ -284,7 +284,7 @@ def cmpltn_reset(self) -> None: def get_stem(self) -> str: st = self.syntax_table - SW = reader.SYNTAX_WORD + SW = SYNTAX_WORD b = self.buffer p = self.pos - 1 while p >= 0 and st.get(b[p], SW) == SW: diff --git a/Lib/_pyrepl/historical_reader.py b/Lib/_pyrepl/historical_reader.py index c4b95fa2e81ee6..dd036b3d87f761 100644 --- a/Lib/_pyrepl/historical_reader.py +++ b/Lib/_pyrepl/historical_reader.py @@ -26,7 +26,9 @@ from .reader import Reader -if False: +TYPE_CHECKING = False + +if TYPE_CHECKING: from .types import SimpleContextManager, KeySpec, CommandName diff --git a/Lib/_pyrepl/input.py b/Lib/_pyrepl/input.py index 21c24eb5cde3e3..a51c65a0d0c24c 100644 --- a/Lib/_pyrepl/input.py +++ b/Lib/_pyrepl/input.py @@ -40,8 +40,9 @@ from collections import deque -# types -if False: +TYPE_CHECKING = False + +if TYPE_CHECKING: from .types import EventTuple diff --git a/Lib/_pyrepl/pager.py b/Lib/_pyrepl/pager.py index 1fddc63e3ee3ad..0e8770d83f36b0 100644 --- a/Lib/_pyrepl/pager.py +++ b/Lib/_pyrepl/pager.py @@ -5,9 +5,9 @@ import re import sys +TYPE_CHECKING = False -# types -if False: +if TYPE_CHECKING: from typing import Protocol class Pager(Protocol): def __call__(self, text: str, title: str = "") -> None: diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py index 1252847e02b2ea..775c842a9ad246 100644 --- a/Lib/_pyrepl/reader.py +++ b/Lib/_pyrepl/reader.py @@ -32,11 +32,14 @@ from . import commands, console, input from .utils import ANSI_ESCAPE_SEQUENCE, wlen, str_width from .trace import trace +from .types import Callback +TYPE_CHECKING = False + +if TYPE_CHECKING: + from .types import SimpleContextManager, KeySpec, CommandName -# types Command = commands.Command -from .types import Callback, SimpleContextManager, KeySpec, CommandName def disp_str(buffer: str) -> tuple[str, list[int]]: diff --git a/Lib/_pyrepl/readline.py b/Lib/_pyrepl/readline.py index 888185eb03be66..6ab122fb73c87f 100644 --- a/Lib/_pyrepl/readline.py +++ b/Lib/_pyrepl/readline.py @@ -28,7 +28,6 @@ from __future__ import annotations -import warnings from dataclasses import dataclass, field import os @@ -39,7 +38,10 @@ from . import commands, historical_reader from .completing_reader import CompletingReader from .console import Console as ConsoleType +from .types import Callback, Completer, KeySpec, CommandName +from collections.abc import Callable, Collection +MoreLinesCallable = Callable[[str], bool] Console: type[ConsoleType] _error: tuple[type[Exception], ...] | type[Exception] try: @@ -47,21 +49,12 @@ except ImportError: from .windows_console import WindowsConsole as Console, _error -ENCODING = sys.getdefaultencoding() or "latin1" - - -# types -Command = commands.Command -from collections.abc import Callable, Collection -from .types import Callback, Completer, KeySpec, CommandName - TYPE_CHECKING = False if TYPE_CHECKING: from typing import Any, Mapping - -MoreLinesCallable = Callable[[str], bool] +ENCODING = sys.getdefaultencoding() or "latin1" __all__ = [ @@ -183,7 +176,7 @@ def collect_keymap(self) -> tuple[tuple[KeySpec, CommandName], ...]: (r"\", "backspace-dedent"), ) - def after_command(self, cmd: Command) -> None: + def after_command(self, cmd: commands.Command) -> None: super().after_command(cmd) if self.more_lines is None: # Force single-line input if we are in raw_input() mode. @@ -377,6 +370,8 @@ def multiline_input(self, more_lines: MoreLinesCallable, ps1: str, ps2: str) -> lines as long as 'more_lines(unicodetext)' returns an object whose boolean value is true. """ + import warnings + reader = self.get_reader() saved = reader.more_lines try: diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index a065174ad42fb6..c727c400f416ac 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -30,15 +30,13 @@ import functools import os import sys -import code -from .readline import _get_reader, multiline_input +from .readline import _get_reader, multiline_input, _setup TYPE_CHECKING = False if TYPE_CHECKING: - from typing import Any - + from code import InteractiveConsole _error: tuple[type[Exception], ...] | type[Exception] try: @@ -46,6 +44,7 @@ except ModuleNotFoundError: from .windows_console import _error + def check() -> str: """Returns the error message if there is a problem initializing the state.""" try: @@ -83,7 +82,7 @@ def _clear_screen(): } -def _more_lines(console: code.InteractiveConsole, unicodetext: str) -> bool: +def _more_lines(console: InteractiveConsole, unicodetext: str) -> bool: # ooh, look at the hack: src = _strip_final_indent(unicodetext) try: @@ -103,11 +102,10 @@ def _more_lines(console: code.InteractiveConsole, unicodetext: str) -> bool: def run_multiline_interactive_console( - console: code.InteractiveConsole, + console: InteractiveConsole, *, future_flags: int = 0, ) -> None: - from .readline import _setup _setup(console.locals) if future_flags: console.compile.compiler.flags |= future_flags diff --git a/Lib/_pyrepl/trace.py b/Lib/_pyrepl/trace.py index a8eb2433cd3cce..5781f9134d5889 100644 --- a/Lib/_pyrepl/trace.py +++ b/Lib/_pyrepl/trace.py @@ -2,8 +2,9 @@ import os -# types -if False: +TYPE_CHECKING = False + +if TYPE_CHECKING: from typing import IO diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py index 96379bc20f3357..a5f91c8b49ba22 100644 --- a/Lib/_pyrepl/unix_console.py +++ b/Lib/_pyrepl/unix_console.py @@ -39,10 +39,8 @@ from .unix_eventqueue import EventQueue from .utils import wlen - TYPE_CHECKING = False -# types if TYPE_CHECKING: from typing import IO, Literal, overload else: diff --git a/Lib/_pyrepl/windows_console.py b/Lib/_pyrepl/windows_console.py index e1ecd9845aefb4..1863a58cae3483 100644 --- a/Lib/_pyrepl/windows_console.py +++ b/Lib/_pyrepl/windows_console.py @@ -26,7 +26,6 @@ import msvcrt from collections import deque -import ctypes from ctypes.wintypes import ( _COORD, WORD, @@ -45,7 +44,7 @@ try: from ctypes import GetLastError, WinDLL, windll, WinError # type: ignore[attr-defined] -except: +except ImportError: # Keep MyPy happy off Windows from ctypes import CDLL as WinDLL, cdll as windll @@ -531,7 +530,7 @@ class Char(Union): ] -class KeyEvent(ctypes.Structure): +class KeyEvent(Structure): _fields_ = [ ("bKeyDown", BOOL), ("wRepeatCount", WORD), @@ -542,11 +541,11 @@ class KeyEvent(ctypes.Structure): ] -class WindowsBufferSizeEvent(ctypes.Structure): +class WindowsBufferSizeEvent(Structure): _fields_ = [("dwSize", _COORD)] -class ConsoleEvent(ctypes.Union): +class ConsoleEvent(Union): _fields_ = [ ("KeyEvent", KeyEvent), ("WindowsBufferSizeEvent", WindowsBufferSizeEvent), @@ -580,7 +579,7 @@ class INPUT_RECORD(Structure): GetConsoleScreenBufferInfo = _KERNEL32.GetConsoleScreenBufferInfo GetConsoleScreenBufferInfo.argtypes = [ HANDLE, - ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO), + POINTER(CONSOLE_SCREEN_BUFFER_INFO), ] GetConsoleScreenBufferInfo.restype = BOOL From 6a7a07e398a1f5e25df72663942e35ebe6e35c91 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 14:40:02 +0400 Subject: [PATCH 02/14] Revert unrelated changes --- Lib/_pyrepl/completing_reader.py | 11 ++++++----- Lib/_pyrepl/readline.py | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Lib/_pyrepl/completing_reader.py b/Lib/_pyrepl/completing_reader.py index 79b0b2914ab7cc..1715bb99bdb39d 100644 --- a/Lib/_pyrepl/completing_reader.py +++ b/Lib/_pyrepl/completing_reader.py @@ -23,15 +23,16 @@ from dataclasses import dataclass, field import re -from . import commands, console -from .reader import Reader, SYNTAX_WORD - +from . import commands, console, reader +from .reader import Reader TYPE_CHECKING = False if TYPE_CHECKING: from .types import KeySpec, CommandName +Command = commands.Command + def prefix(wordlist: list[str], j: int = 0) -> str: d = {} @@ -252,7 +253,7 @@ def collect_keymap(self) -> tuple[tuple[KeySpec, CommandName], ...]: return super().collect_keymap() + ( (r'\t', 'complete'),) - def after_command(self, cmd: commands.Command) -> None: + def after_command(self, cmd: Command) -> None: super().after_command(cmd) if not isinstance(cmd, (complete, self_insert)): self.cmpltn_reset() @@ -284,7 +285,7 @@ def cmpltn_reset(self) -> None: def get_stem(self) -> str: st = self.syntax_table - SW = SYNTAX_WORD + SW = reader.SYNTAX_WORD b = self.buffer p = self.pos - 1 while p >= 0 and st.get(b[p], SW) == SW: diff --git a/Lib/_pyrepl/readline.py b/Lib/_pyrepl/readline.py index 6ab122fb73c87f..203caba896fa9e 100644 --- a/Lib/_pyrepl/readline.py +++ b/Lib/_pyrepl/readline.py @@ -54,6 +54,7 @@ if TYPE_CHECKING: from typing import Any, Mapping +Command = commands.Command ENCODING = sys.getdefaultencoding() or "latin1" @@ -176,7 +177,7 @@ def collect_keymap(self) -> tuple[tuple[KeySpec, CommandName], ...]: (r"\", "backspace-dedent"), ) - def after_command(self, cmd: commands.Command) -> None: + def after_command(self, cmd: Command) -> None: super().after_command(cmd) if self.more_lines is None: # Force single-line input if we are in raw_input() mode. From afbf3ff4c78ed0d6e6756aaa3eca526f4d719a65 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 15:02:02 +0400 Subject: [PATCH 03/14] Revert more --- Lib/_pyrepl/reader.py | 8 ++------ Lib/_pyrepl/readline.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py index 775c842a9ad246..fc188ad5ab8246 100644 --- a/Lib/_pyrepl/reader.py +++ b/Lib/_pyrepl/reader.py @@ -32,14 +32,10 @@ from . import commands, console, input from .utils import ANSI_ESCAPE_SEQUENCE, wlen, str_width from .trace import trace -from .types import Callback - -TYPE_CHECKING = False - -if TYPE_CHECKING: - from .types import SimpleContextManager, KeySpec, CommandName +# types Command = commands.Command +from .types import Callback, SimpleContextManager, KeySpec, CommandName def disp_str(buffer: str) -> tuple[str, list[int]]: diff --git a/Lib/_pyrepl/readline.py b/Lib/_pyrepl/readline.py index 203caba896fa9e..724b7dd3933a44 100644 --- a/Lib/_pyrepl/readline.py +++ b/Lib/_pyrepl/readline.py @@ -38,10 +38,7 @@ from . import commands, historical_reader from .completing_reader import CompletingReader from .console import Console as ConsoleType -from .types import Callback, Completer, KeySpec, CommandName -from collections.abc import Callable, Collection -MoreLinesCallable = Callable[[str], bool] Console: type[ConsoleType] _error: tuple[type[Exception], ...] | type[Exception] try: @@ -49,13 +46,21 @@ except ImportError: from .windows_console import WindowsConsole as Console, _error +ENCODING = sys.getdefaultencoding() or "latin1" + + +# types +Command = commands.Command +from collections.abc import Callable, Collection +from .types import Callback, Completer, KeySpec, CommandName + TYPE_CHECKING = False if TYPE_CHECKING: from typing import Any, Mapping -Command = commands.Command -ENCODING = sys.getdefaultencoding() or "latin1" + +MoreLinesCallable = Callable[[str], bool] __all__ = [ From 57f20fec4b8836dcbee9572d375bc978fb8e1c79 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 11:34:48 +0000 Subject: [PATCH 04/14] Update Lib/_pyrepl/simple_interact.py Co-authored-by: sobolevn --- Lib/_pyrepl/simple_interact.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index c727c400f416ac..c7179fda251b53 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -44,7 +44,6 @@ except ModuleNotFoundError: from .windows_console import _error - def check() -> str: """Returns the error message if there is a problem initializing the state.""" try: From 2f9700606ef3ae3780dc885119fa72fa7e9c3598 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 11:34:58 +0000 Subject: [PATCH 05/14] Update Lib/_pyrepl/reader.py Co-authored-by: sobolevn --- Lib/_pyrepl/reader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py index fc188ad5ab8246..1252847e02b2ea 100644 --- a/Lib/_pyrepl/reader.py +++ b/Lib/_pyrepl/reader.py @@ -33,6 +33,7 @@ from .utils import ANSI_ESCAPE_SEQUENCE, wlen, str_width from .trace import trace + # types Command = commands.Command from .types import Callback, SimpleContextManager, KeySpec, CommandName From 7eb0a1c2fbb0def8ba4ba6cfdb416c81f449aa13 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 11:35:21 +0000 Subject: [PATCH 06/14] Update Lib/_pyrepl/_threading_handler.py Co-authored-by: sobolevn --- Lib/_pyrepl/_threading_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/_pyrepl/_threading_handler.py b/Lib/_pyrepl/_threading_handler.py index 67794d62f16136..82f5e8650a2072 100644 --- a/Lib/_pyrepl/_threading_handler.py +++ b/Lib/_pyrepl/_threading_handler.py @@ -3,8 +3,8 @@ from dataclasses import dataclass, field import traceback -TYPE_CHECKING = False +TYPE_CHECKING = False if TYPE_CHECKING: from threading import Thread from types import TracebackType From 1444ba104207a2c3c61604b2a424619bae3d750e Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 11:36:17 +0000 Subject: [PATCH 07/14] Update Lib/_pyrepl/unix_console.py Co-authored-by: sobolevn --- Lib/_pyrepl/unix_console.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py index a5f91c8b49ba22..d9748c5d626c75 100644 --- a/Lib/_pyrepl/unix_console.py +++ b/Lib/_pyrepl/unix_console.py @@ -39,8 +39,9 @@ from .unix_eventqueue import EventQueue from .utils import wlen -TYPE_CHECKING = False +TYPE_CHECKING = False +# types if TYPE_CHECKING: from typing import IO, Literal, overload else: From 83804c97f64e7c14aed75d347bb2db2524898d93 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 16:11:30 +0000 Subject: [PATCH 08/14] Update Lib/_pyrepl/pager.py Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Lib/_pyrepl/pager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/_pyrepl/pager.py b/Lib/_pyrepl/pager.py index 0e8770d83f36b0..e0c4a0d66bdc37 100644 --- a/Lib/_pyrepl/pager.py +++ b/Lib/_pyrepl/pager.py @@ -5,8 +5,8 @@ import re import sys -TYPE_CHECKING = False +TYPE_CHECKING = False if TYPE_CHECKING: from typing import Protocol class Pager(Protocol): From 03174a777a583f6f3f0bfa27538088d380521139 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 16:11:44 +0000 Subject: [PATCH 09/14] Update Lib/_pyrepl/simple_interact.py Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Lib/_pyrepl/simple_interact.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index c7179fda251b53..4eeadf2a5796fc 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -38,6 +38,7 @@ if TYPE_CHECKING: from code import InteractiveConsole + _error: tuple[type[Exception], ...] | type[Exception] try: from .unix_console import _error From 8d5ef4638a669d00d9e59ea682d9fee73cf19149 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 16:12:12 +0000 Subject: [PATCH 10/14] Update Lib/_pyrepl/completing_reader.py Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Lib/_pyrepl/completing_reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/_pyrepl/completing_reader.py b/Lib/_pyrepl/completing_reader.py index 1715bb99bdb39d..c5b748b1b9869a 100644 --- a/Lib/_pyrepl/completing_reader.py +++ b/Lib/_pyrepl/completing_reader.py @@ -26,8 +26,8 @@ from . import commands, console, reader from .reader import Reader -TYPE_CHECKING = False +TYPE_CHECKING = False if TYPE_CHECKING: from .types import KeySpec, CommandName From 7ac543f526f210ca94347d7fa8f4700a1ec9cf95 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 16:13:08 +0000 Subject: [PATCH 11/14] Update Lib/_pyrepl/simple_interact.py Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Lib/_pyrepl/simple_interact.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index 4eeadf2a5796fc..6beb2c45aeedb8 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -34,7 +34,6 @@ from .readline import _get_reader, multiline_input, _setup TYPE_CHECKING = False - if TYPE_CHECKING: from code import InteractiveConsole From 8e96d24e90206776eec587c6edbd4f27ddf195f3 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 20:19:31 +0400 Subject: [PATCH 12/14] Revert improvements :-) --- Lib/_pyrepl/commands.py | 1 - Lib/_pyrepl/historical_reader.py | 1 - Lib/_pyrepl/input.py | 1 - Lib/_pyrepl/readline.py | 3 +-- Lib/_pyrepl/windows_console.py | 2 +- 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Lib/_pyrepl/commands.py b/Lib/_pyrepl/commands.py index 9bd3af33c522a5..ca1d29b125252c 100644 --- a/Lib/_pyrepl/commands.py +++ b/Lib/_pyrepl/commands.py @@ -33,7 +33,6 @@ TYPE_CHECKING = False - if TYPE_CHECKING: from .historical_reader import HistoricalReader diff --git a/Lib/_pyrepl/historical_reader.py b/Lib/_pyrepl/historical_reader.py index dd036b3d87f761..8474fe0bef85dc 100644 --- a/Lib/_pyrepl/historical_reader.py +++ b/Lib/_pyrepl/historical_reader.py @@ -27,7 +27,6 @@ TYPE_CHECKING = False - if TYPE_CHECKING: from .types import SimpleContextManager, KeySpec, CommandName diff --git a/Lib/_pyrepl/input.py b/Lib/_pyrepl/input.py index a51c65a0d0c24c..0081937f1e1181 100644 --- a/Lib/_pyrepl/input.py +++ b/Lib/_pyrepl/input.py @@ -41,7 +41,6 @@ TYPE_CHECKING = False - if TYPE_CHECKING: from .types import EventTuple diff --git a/Lib/_pyrepl/readline.py b/Lib/_pyrepl/readline.py index 724b7dd3933a44..888185eb03be66 100644 --- a/Lib/_pyrepl/readline.py +++ b/Lib/_pyrepl/readline.py @@ -28,6 +28,7 @@ from __future__ import annotations +import warnings from dataclasses import dataclass, field import os @@ -376,8 +377,6 @@ def multiline_input(self, more_lines: MoreLinesCallable, ps1: str, ps2: str) -> lines as long as 'more_lines(unicodetext)' returns an object whose boolean value is true. """ - import warnings - reader = self.get_reader() saved = reader.more_lines try: diff --git a/Lib/_pyrepl/windows_console.py b/Lib/_pyrepl/windows_console.py index 1863a58cae3483..6322b872663037 100644 --- a/Lib/_pyrepl/windows_console.py +++ b/Lib/_pyrepl/windows_console.py @@ -44,7 +44,7 @@ try: from ctypes import GetLastError, WinDLL, windll, WinError # type: ignore[attr-defined] -except ImportError: +except: # Keep MyPy happy off Windows from ctypes import CDLL as WinDLL, cdll as windll From 616405b9eaca52e615c2ec8a7e6f1b497eeadd65 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 16:20:43 +0000 Subject: [PATCH 13/14] Update Lib/_pyrepl/trace.py Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Lib/_pyrepl/trace.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/_pyrepl/trace.py b/Lib/_pyrepl/trace.py index 5781f9134d5889..86d5aa41c8db3d 100644 --- a/Lib/_pyrepl/trace.py +++ b/Lib/_pyrepl/trace.py @@ -3,7 +3,6 @@ import os TYPE_CHECKING = False - if TYPE_CHECKING: from typing import IO From 7281903fd9f56211c27e48878b8060ec2537e4bc Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Feb 2025 16:20:57 +0000 Subject: [PATCH 14/14] Update Lib/_pyrepl/unix_console.py Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Lib/_pyrepl/unix_console.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py index d9748c5d626c75..2171e58fa192ee 100644 --- a/Lib/_pyrepl/unix_console.py +++ b/Lib/_pyrepl/unix_console.py @@ -41,7 +41,6 @@ TYPE_CHECKING = False -# types if TYPE_CHECKING: from typing import IO, Literal, overload else: