Commit Graph

5870 Commits

Author SHA1 Message Date
timrid
0dcd0640ca fixed 'str' to 'wxString' converstation, when emoji is inside string (fixes #2446) 2023-11-27 09:59:05 +01:00
Kazuya O'moto
1fb1e84012 Use unwrap before isbuiltin check
`inspect.isbuiltin` does not unwrap obj, but `inspect.signature` does,
which can result in a ValueError.

    >>> wx.Bell
    <built-in function Bell>
    >>> bell #= dcor(wx.Bell)
    <function Bell at 0x0000015E53D92B60>
    >>> inspect.isbuiltin(bell)
    False
    >>> inspect.signature(bell)
    ... (snip) ...
    ValueError: no signature found for builtin <built-in function Bell>
2023-11-26 16:32:57 +09:00
Scott Talbert
172e732a0c Merge pull request #2478 from swt2c/wx3.2.4
Update wxWidgets to v3.2.4
2023-11-23 10:09:22 -05:00
Scott Talbert
7a198b8cae Update wxTextCtrl OSX overrides since they're now documented 2023-11-20 22:12:58 -05:00
Scott Talbert
6e2065bbfd Update wxWidgets to v3.2.4 2023-11-13 20:12:39 -05:00
Jorge Moraleda
9084de5a6f Pure python AUI: Make behavior in all platforms more equal. This also reduces flicker, reduces number of code lines by removing platform exception. 2023-11-11 19:22:03 -05:00
Scott Talbert
11c4a77788 Merge pull request #2470 from jmoraleda/mycontrib/pdfviewer-use-int-sizes-when-printing
Bugfix. Explicitly convert float to int when calling to wx.Size in pdfviewer
2023-10-30 11:01:07 -04:00
Scott Talbert
0b19a4a671 Merge pull request #2456 from swt2c/python3.12
Add CI for Python 3.12 (and drop EOL Python 3.7)
2023-10-30 09:15:44 -04:00
Scott Talbert
e1c0738221 Windows CI: remove extra MSVC configuration
Due to there being multiple MSVC versions installed on the Azure images,
the build process seems to be getting parts of both of them, so remove
the older one.
2023-10-29 21:05:29 -04:00
Jorge Moraleda
0cf08c27fd Explicitly convert float to int when calling to wx.Size in pure python pdfviewer 2023-10-27 18:45:16 -04:00
Scott Talbert
e271c80cd8 Merge pull request #2469 from 1marc1/patch-1
Update typo in persist_handlers.py
2023-10-27 09:10:47 -04:00
1marc1
f773bb444d Update typo in persist_handlers.py
This should fix a typo in the return statement.
2023-10-27 23:45:17 +11:00
Scott Talbert
5444f4c3e6 Add CI for Python 3.12 (and drop EOL Python 3.7) 2023-10-23 20:52:17 -04:00
lojack5
17cbd02543 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).
2023-10-18 22:46:32 -06:00
lojack5
51675584d8 Tentative: fix for ParamSpec on Python < 3.10
Alternate solution is to remove the callable typing on CallAfter and CallLater
2023-10-18 21:28:02 -06:00
lojack5
1bdc66afc6 Python <3.10 typing compat: Callable
`collections.abc.Callable` subscripting was added in Python 3.10,
use `typing.Callable` instead.
2023-10-18 14:18:22 -06:00
lojack5
804d3f15e3 fixup: union commit 2023-10-18 14:18:21 -06:00
lojack5
b23c5a83dc Python <3.9 typing compat: tuples
Subscripting builtins.tuple was added in Python 3.9, so use
`typing.Tuple` where applicable.
2023-10-18 13:10:24 -06:00
lojack5
2ea917b0b5 Python <3.9 typing compat: list
Subscribing builtins.list wasn't added until Python 3.9 so use
`typing.List` where applicable.
2023-10-18 13:08:54 -06:00
lojack5
17438ac318 Python <3.10 typing compat: unions
Use `typing.Optional` and `typing.Union` where applicable, as direct
union (`|`) type annotations were added in Python 3.10
2023-10-18 13:06:31 -06:00
lojack5
3958d89217 Optional fixing of wx prefix in cleanName
This fixes erroneous wx. prepended to `version` variable in methods'
parameters.
2023-10-18 12:27:00 -06:00
lojack5
1fa0df5db5 Add typing to handwritten code for core.pyi 2023-10-18 12:27:00 -06:00
lojack5
3d5290f46c Another type-conversion edge case: void -> Any 2023-10-18 12:27:00 -06:00
lojack5
e84d7abcba Possible way to handle enums.
Named enums with 'Flags' in the name use `enum.IntFlag`, all other enums
use `enum.IntEnum`.  We have to bring the enum members into the containing
scope to match the original behaviour. Further, since these enums are typing
information only, and not actually in wx proper, we prevent them from appearing
to leak the the user by marking as non-exported (prepend '_' to the name), then
make a TypeAlias to the enum or an int.  This way type signatures still claim
to accept integers as appropriate.

I like this solution best, because we preserved the information about which
enum members are expected for method/function parameters, while not leaking
non-existant classes out of the type-stubs, and not complaining about using
integers.

There's still a few undefined but referenced enums (ex:
richtext.TextAttrDimensionFlags). These are most likely a union of some of
the other flags/enum types already defined, but the work to pull that information
from the C++ source is probably too much.
2023-10-18 12:27:00 -06:00
lojack5
e14be4fbb4 Edge case on type-conversions: typdef int wxCoord 2023-10-18 12:26:59 -06:00
lojack5
ec15761d5b Better generated global variables
Use the more generic type rather than a literal type. Before, a type-checker
would infer an int defined this way as `Literal[0]` vs the more correctly
generic `int` for example.
2023-10-18 12:26:59 -06:00
lojack5
3e634c0794 Better generated member variables 2023-10-18 12:26:59 -06:00
lojack5
7aad3d4c70 Better generated properties
By directly referencing their setter and getter methods,
and due to the typing work already done for methods, we now have
type information attached to properties.

There are a few edge cases of setters/getters not having the proper
number of arguments for a getter(0) or setter(1), but most cases are
handled. The incorrect number of arguments may be missing default
arguments from what the extraction code figures out from the C++ code?
2023-10-18 12:26:59 -06:00
lojack5
2c6100cead Enable return-type annotations
With the work from the previous commits, it's as simple as
no longer lopping off the args string at the '->' marker.
(And one minor fixup to the makePyArgsString code).
2023-10-18 12:26:58 -06:00
lojack5
6b6b810cc4 Process overloaded functions and methods 2023-10-18 12:26:58 -06:00
lojack5
7f74a5fd65 Prepare for changes in generated #define and global variables
These will be changing to annotation statements, so FixWxPrefix needs to
be able to detect this still (proper thing to look for in this case is
`ast.AnnAssign`).
2023-10-18 12:26:58 -06:00
lojack5
fa2bde419f Extract type information in makePyArgsString
One unexpected type of '...' required adding a new transformation
that modifies both the name and the type to just '*args', so added
a preferred method `FixWxPrefix.parseNameAndType` which processes
both strings at once.

Also fixes cleanType to recursively call cleanType on sub-types
(was improperly calling cleanName).

With this, method and function signatures now have type annotations
which are mostly correct (100% correct in the "it compiles" sense).
Thankfully, the incorrect type-hints don't cause errors due to using
stringized annotations (by importing annotations from __future__).

Importantly, the overload signatures now have been fully sanitized.
Before this, there was one instance of a variable named `is`, and another
named `/Transfer/` - both invalid identifiers. I stopped looking after
those. Since theses signatures are valid Python code, this opens up the
opportunity to use `typing.overload` to fully expose those.

Edge-cases in type-hints will be addressed in later commits.
2023-10-18 12:26:58 -06:00
lojack5
a28de82bbb Ensure needed imports from typing are included in type-stubs
Leverages the `writeSection` machinery, with a tweak to specify to add a
new section to the beginning of a file, after the header. This ensures
the required imports gets updated (and also only imported once per file)
if new imports are needed for type-hints. Hint: there's a few more to come.
2023-10-18 12:26:10 -06:00
lojack5
d303548d43 Move local _cleanName to FixWxPrefix.cleanName
This allows for building `FixWxPrefix.cleanType` on top of it, for use
in processing type-hint strings in the future. It also exposes the method
to `FunctionDef.makePyArgString` in the future, which has easier access to
the types of arguments and returns. And possibly further in the future,
other `***Def` classes can make use of it (constant definitions, etc).
2023-10-18 12:19:00 -06:00
lojack5
07de1d515e [etgtools] Disable text wrapping for specific lines in docstrings
The line-wrapping causes issues once the python signatures become too long,
as textwrap isn't smart enough to split the lines on valid continuation points
for code. I had one instance of splitting a line in the middle of a string ->
SyntaxError on next run of etg due to the generated PYI file having an
unterminated string.

Specificially, disable splitting for lines that start (ignoring spaces) with
a specific string - in this case any line starting with the name of the
function or method this is a docstring for.
2023-10-18 12:18:48 -06:00
Tomas Zigo
53574e37ad wx.agw.aui: don't uninitialize the AuiManager if the window close event is vetoed 2023-09-22 08:07:21 +02:00
Stefan Brüns
5dceaa3ebe Make pip usage in wxget optional
As the code states, using pip to download is abusing it, and it is
just a fallback in case neither wget nor urllib works.
2023-09-11 17:33:51 +02:00
Robin Dunn
a118428670 Merge branch 'exclude-pillow' 2023-08-30 22:38:01 -07:00
Robin Dunn
e07dcb8733 Just remove the Pillow dependency until this issue can get worked out 2023-08-30 16:13:28 -07:00
Robin Dunn
e95b6c8b4e Pin pillow to < 3.0 until they add a Windows 32bit build or we drop it. 2023-08-29 18:35:09 -07:00
Robin Dunn
e01138a0bf add note about PGP signatures 2023-08-29 13:51:35 -07:00
Tianzhu Qiao
4eb797e8ed Fix AuiManager pane minimizing issue. 2023-08-17 10:59:16 -07:00
Scott Talbert
e4fd9a3e04 Merge pull request #2443 from swt2c/safer_tar
Use new tarfile.extractall() filter for safer tarfile extraction
2023-08-04 17:28:56 -04:00
Scott Talbert
e5c92b3056 Use new tarfile.extractall() filter for safer tarfile extraction
The tarfile.extractall() filter argument was introduced in the most
recent CPython releases (e.g., 3.11.4) to avoid potential security
issues when extracting from potentially hostile tarballs.  Let's use
this option if it is available and provide a warning if it is now.
2023-08-03 16:25:07 -04:00
Scott Talbert
82b9b5b542 Merge pull request #2440 from swt2c/sip_6.7.10
Update sip to v6.7.11
2023-08-02 11:46:22 -04:00
Scott Talbert
d17fff1795 Update sip to v6.7.11 2023-08-02 08:54:22 -04:00
Scott Talbert
1f82021f38 Merge pull request #2441 from swt2c/fix_cython3_support
Fix compatibility with Cython 3.0.0
2023-07-25 14:50:39 -04:00
Scott Talbert
aeb557d01e Fix compatibility with Cython 3.0.0
Remove unused import which seems to be removed in Cython 3.
2023-07-25 12:42:32 -04:00
Scott Talbert
dac1e86423 Merge pull request #2018 from pauldmccarthy/mnt/wx-lib-agw-aui-mac-theme
MNT: Remove legacy macOS logic, and use wx.SystemSettings to select default colours
2023-07-19 12:22:02 -04:00
Scott Talbert
83db65a23c Merge pull request #2438 from swt2c/prefer_binary
Try preferring binary to fix Windows CI
2023-07-15 08:58:58 -04:00