mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
fixup: Non-generated core.pyi code
Since this is used to not only generate the type-stubs, but also the actual wx/core.py, we need to ensure TypeVar and ParamSpec are imported there as well. So, move the imports to the wx/core.py generator definition, and remove the imports from the type-stub generator (these imports are only used by CallAfter and CallLater).
This commit is contained in:
17
etg/_core.py
17
etg/_core.py
@@ -291,11 +291,16 @@ def run():
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
module.addPyCode('import typing', order=10)
|
||||||
module.addPyCode("""\
|
module.addPyCode("""\
|
||||||
_T = TypeVar('_T')
|
_T = typing.TypeVar('_T')
|
||||||
_P = ParamSpec('_P')
|
try:
|
||||||
|
_P = typing.ParamSpec('_P')
|
||||||
|
except AttributeError:
|
||||||
|
import typing_extensions
|
||||||
|
_P = typing_extensions.ParamSpec('_P')
|
||||||
""")
|
""")
|
||||||
module.addPyFunction('CallAfter', '(callableObj: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> None', doc="""\
|
module.addPyFunction('CallAfter', '(callableObj: typing.Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> None', doc="""\
|
||||||
Call the specified function after the current and pending event
|
Call the specified function after the current and pending event
|
||||||
handlers have been completed. This is also good for making GUI
|
handlers have been completed. This is also good for making GUI
|
||||||
method calls from non-GUI threads. Any extra positional or
|
method calls from non-GUI threads. Any extra positional or
|
||||||
@@ -326,7 +331,7 @@ def run():
|
|||||||
wx.PostEvent(app, evt)""")
|
wx.PostEvent(app, evt)""")
|
||||||
|
|
||||||
|
|
||||||
module.addPyClass('CallLater', ['Generic[_P, _T]'],
|
module.addPyClass('CallLater', ['typing.Generic[_P, _T]'],
|
||||||
doc="""\
|
doc="""\
|
||||||
A convenience class for :class:`wx.Timer`, that calls the given callable
|
A convenience class for :class:`wx.Timer`, that calls the given callable
|
||||||
object once after the given amount of milliseconds, passing any
|
object once after the given amount of milliseconds, passing any
|
||||||
@@ -346,7 +351,7 @@ def run():
|
|||||||
""",
|
""",
|
||||||
items = [
|
items = [
|
||||||
PyCodeDef('__instances = {}'),
|
PyCodeDef('__instances = {}'),
|
||||||
PyFunctionDef('__init__', '(self, millis, callableObj: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> None',
|
PyFunctionDef('__init__', '(self, millis, callableObj: typing.Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> None',
|
||||||
doc="""\
|
doc="""\
|
||||||
Constructs a new :class:`wx.CallLater` object.
|
Constructs a new :class:`wx.CallLater` object.
|
||||||
|
|
||||||
@@ -370,7 +375,7 @@ def run():
|
|||||||
|
|
||||||
PyFunctionDef('__del__', '(self)', 'self.Stop()'),
|
PyFunctionDef('__del__', '(self)', 'self.Stop()'),
|
||||||
|
|
||||||
PyFunctionDef('Start', '(self, millis: int | None=None, *args: _P.args, **kwargs: _P.kwargs) -> None',
|
PyFunctionDef('Start', '(self, millis: typing.Optional[int]=None, *args: _P.args, **kwargs: _P.kwargs) -> None',
|
||||||
doc="""\
|
doc="""\
|
||||||
(Re)start the timer
|
(Re)start the timer
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ header_pyi = """\
|
|||||||
typing_imports = """\
|
typing_imports = """\
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from enum import IntEnum, IntFlag, auto
|
from enum import IntEnum, IntFlag, auto
|
||||||
from typing import (Any, overload, TypeAlias, TypeVar, ParamSpec, Generic,
|
from typing import (Any, overload, TypeAlias, Generic,
|
||||||
Union, Optional, List, Tuple, Callable
|
Union, Optional, List, Tuple, Callable
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user