Skip to content

Commit 405b1bd

Browse files
tungolAlexWaygood
andauthored
curses._ncurses_version updates (#13023)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent 2a1a222 commit 405b1bd

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

stdlib/_curses.pyi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from _typeshed import ReadOnlyBuffer, SupportsRead
3-
from typing import IO, Any, NamedTuple, final, overload
3+
from curses import _ncurses_version
4+
from typing import IO, Any, final, overload
45
from typing_extensions import TypeAlias
56

67
# NOTE: This module is ordinarily only available on Unix, but the windows-curses
@@ -549,9 +550,4 @@ class window: # undocumented
549550
@overload
550551
def vline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
551552

552-
class _ncurses_version(NamedTuple):
553-
major: int
554-
minor: int
555-
patch: int
556-
557553
ncurses_version: _ncurses_version

stdlib/curses/__init__.pyi

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import sys
12
from _curses import *
23
from _curses import window as window
4+
from _typeshed import structseq
35
from collections.abc import Callable
4-
from typing import TypeVar
6+
from typing import Final, TypeVar, final, type_check_only
57
from typing_extensions import Concatenate, ParamSpec
68

79
# NOTE: The _curses module is ordinarily only available on Unix, but the
@@ -25,3 +27,19 @@ def wrapper(func: Callable[Concatenate[window, _P], _T], /, *arg: _P.args, **kwd
2527
# it was mapped to the name 'window' in 3.8.
2628
# Kept here as a legacy alias in case any third-party code is relying on it.
2729
_CursesWindow = window
30+
31+
# At runtime this class is unexposed and calls itself curses.ncurses_version.
32+
# That name would conflict with the actual curses.ncurses_version, which is
33+
# an instance of this class.
34+
@final
35+
@type_check_only
36+
class _ncurses_version(structseq[int], tuple[int, int, int]):
37+
if sys.version_info >= (3, 10):
38+
__match_args__: Final = ("major", "minor", "patch")
39+
40+
@property
41+
def major(self) -> int: ...
42+
@property
43+
def minor(self) -> int: ...
44+
@property
45+
def patch(self) -> int: ...

0 commit comments

Comments
 (0)