Commit Graph

5648 Commits

Author SHA1 Message Date
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
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
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
Scott Talbert
d7a201df4f Try preferring binary to fix Windows CI 2023-07-14 20:38:01 -04:00
Scott Talbert
74e34c7a2c Merge pull request #2425 from konstantinbo/fix-dataviewcheckicontextrenderer
Fix dataviewcheckicontextrenderer
2023-07-14 17:09:41 -04:00
Scott Talbert
371101db7a Handle wxGLCanvas::CreateSurface which is only available on EGL 2023-07-14 14:28:12 -04:00
Scott Talbert
9cfb59d38d Update wxWidgets reference for wxDataViewCheckIconText documentation 2023-07-11 19:27:27 -04:00
Scott Talbert
8e05612415 Merge pull request #2412 from davidfstr/f/fix_shortcut_demo
demo: ShortcutEditor: Fix broken call GetMenuBar()
2023-07-11 19:15:56 -04:00
Scott Talbert
04029bf6f1 Merge pull request #2436 from jmoraleda/freezeto-gridlabelrenderer
Bugfix. Display correct labels in GridWithLabelRenderersMixin when the grid contains frozen rows or columns
2023-07-11 19:15:29 -04:00
Scott Talbert
289a2fa509 Merge pull request #2360 from tianzhuqiao/agw_auinotebook_blurry_tab
Fix blurry text in AuiNotebook tab.
2023-07-11 15:26:17 -04:00
Jorge Moraleda
40f8595a0c Add support for frozen rows and columns to GridWithLabelRenderersMixin 2023-07-09 21:50:38 -04:00
Scott Talbert
b67eef2589 Merge pull request #2434 from swt2c/wximage_clear_pyint
Set missing pyInt on wxImage.Clear
2023-07-06 14:45:03 -04:00
Scott Talbert
cee1118577 Merge pull request #2430 from Ailothaen/dirbrowsebutton_initialvalue
Addition of initialValue parameter to DirBrowseButton constructor
2023-07-06 13:17:34 -04:00
Scott Talbert
db2cef94d0 Set missing pyInt on wxImage.Clear
Fixes #2433.
2023-07-06 12:47:27 -04:00
Ailothaen
ee185422c6 Added initialValue argument to DirBrowseButton constructor and improved documentation 2023-06-29 21:56:30 +02:00
Scott Talbert
c4d2ceed55 Merge pull request #2429 from reticulatus/ulc_movetoitem_division_fix
UltimateListCtrl - Fix arg TypeError when moving to item with variable row height not set
2023-06-29 10:07:50 -04:00
richardt
54981636c5 Fix arg TypeError when moving to item with variable row height not set 2023-06-29 14:39:47 +01:00
Konstantin Bolshakov
d49c6934cf Added unittest for DataViewCheckIconTextRenderer and DataViewCheckIconText 2023-06-27 14:07:21 +02:00
Konstantin Bolshakov
1236562af5 Add proper support for DataViewCheckIconTextRenderer 2023-06-27 14:07:00 +02:00