370 Commits

Author SHA1 Message Date
lojack5
d92db14141 Fixup from conflict resolution 2025-03-13 23:00:49 -06:00
lojack5
3c6854c138 squash 2025-03-13 18:35:14 -06:00
lojack5
68f75d28dc Fixup: using incorrect method names in some cases where they have been renamed 2025-03-13 18:35:14 -06:00
lojack5
2071ae765d Fixup: functions were being generated as if they were methods (had a 'self' parameter) 2025-03-13 18:35:14 -06:00
lojack5
bca7d10602 Implement hinting for types that are automatically converted
This handles any type with a defined `.convertFromPyObject` set in its
sip generator.
2025-03-13 18:35:13 -06:00
lojack5
03d7f1e8c9 reworks how typed-argstrings are handled
Pulls out the data into a separate class, `tweaker_tools.Signature`.
This simplifies stringizing the args string, and allows for some
checks to be written in a much less complex way. The motivator for
this was adding unions to type-hints (for the upcoming automatically
converted python->wx types). This made parsing the already stringized
args string very complex to be able to handle the potential for commas
in `Union`.
2025-03-13 18:35:13 -06:00
lojack5
e76f298bf1 Fix for RichTextLineVector:
This one has probably been in the generated type-stub for ages.
One of the base classes in the generated stub was generated as `RichTextLine*`.
2025-03-13 18:31:40 -06:00
lojack5
58317175cd Correct incorrect remove of wx from argument names 2025-03-13 18:31:40 -06:00
lojack5
86546a4230 generate properties in stubs using decorator syntax where possible 2025-03-13 18:31:39 -06:00
lojack5
58d5b6a27d mark values #defineed as true or false in the type-stubs as bool. 2025-03-13 18:31:39 -06:00
lojack5
c6cd496e7d Mark subclasses of wx.TopLevelWindow as allowing None for their
`parent` argument.
2025-03-13 18:31:39 -06:00
lojack5
1fe85a8907 mark stubs for __bool__ and __nonzero__ as returning bool. 2025-03-13 18:31:39 -06:00
lojack5
62f820a8cf Fixups for buildings docs (sphinx_generator):
- Remove typehints from argsString before checking signature
- lie and detect `_from`, `_is`, and `_def` as `from`, `is`, and `def for
  signature validating purposes
- Fix: don't remove const from identifiers containing const (eg: constraint)
2025-03-13 18:31:39 -06:00
neofelis2X
0260250cea Docs: fix sphinx error which can't find image path on windows 2025-02-24 23:03:37 +01:00
neofelis2X
b1a931a34b Docs: fix a sphinx warning by stripping trailing whitespace from ref 2025-02-24 23:03:37 +01:00
neofelis2X
78c40585d8 Docs: move a layout tweak from postprocessor to generator 2025-02-24 23:03:37 +01:00
Edouard Choinière
e6c0de4e32 style: Normalise ElementTree imports with import xml.etree.ElementTree as ET
The convention is that `xml.etree.ElementTree` should be imported as `ET`.

Fixes: unconventional-import-alias (ICN001)

Ruff rule: https://docs.astral.sh/ruff/rules/unconventional-import-alias/
2025-02-08 17:04:56 +00:00
Scott Talbert
bb35bcd9d9 Fix bugs in Python2 / six removal 2025-02-03 20:13:56 -05:00
Alexandre Detiste
323e78c085 remove more Python2 hybridation 2025-02-02 20:29:49 -05:00
Scott Talbert
1b5cc2e67a Allow overriding wxSizer.InformFirstDirection()
Some checks are pending
ci-build / build-source-dist (push) Waiting to run
ci-build / build-wheels (x64, macos-13, 3.10) (push) Blocked by required conditions
ci-build / build-wheels (x64, macos-13, 3.11) (push) Blocked by required conditions
ci-build / build-wheels (x64, macos-13, 3.12) (push) Blocked by required conditions
ci-build / build-wheels (x64, macos-13, 3.13) (push) Blocked by required conditions
ci-build / build-wheels (x64, macos-13, 3.9) (push) Blocked by required conditions
ci-build / build-wheels (x64, ubuntu-22.04, 3.10) (push) Blocked by required conditions
ci-build / build-wheels (x64, ubuntu-22.04, 3.11) (push) Blocked by required conditions
ci-build / build-wheels (x64, ubuntu-22.04, 3.12) (push) Blocked by required conditions
ci-build / build-wheels (x64, ubuntu-22.04, 3.13) (push) Blocked by required conditions
ci-build / build-wheels (x64, ubuntu-22.04, 3.9) (push) Blocked by required conditions
ci-build / build-wheels (x64, windows-2022, 3.10) (push) Blocked by required conditions
ci-build / build-wheels (x64, windows-2022, 3.11) (push) Blocked by required conditions
ci-build / build-wheels (x64, windows-2022, 3.12) (push) Blocked by required conditions
ci-build / build-wheels (x64, windows-2022, 3.13) (push) Blocked by required conditions
ci-build / build-wheels (x64, windows-2022, 3.9) (push) Blocked by required conditions
ci-build / build-wheels (x86, windows-2022, 3.10) (push) Blocked by required conditions
ci-build / build-wheels (x86, windows-2022, 3.11) (push) Blocked by required conditions
ci-build / build-wheels (x86, windows-2022, 3.12) (push) Blocked by required conditions
ci-build / build-wheels (x86, windows-2022, 3.13) (push) Blocked by required conditions
ci-build / build-wheels (x86, windows-2022, 3.9) (push) Blocked by required conditions
ci-build / Build wxPython documentation (push) Waiting to run
ci-build / Publish Python distribution to PyPI (push) Blocked by required conditions
ci-build / Create GitHub Release and upload source (push) Blocked by required conditions
ci-build / Upload wheels to snapshot-builds on wxpython.org (push) Blocked by required conditions
It seems this is required in order to implement a non-trivial custom Sizer.

Fixes #2452.
2025-01-26 17:21:08 -05:00
Scott Talbert
2adbeaa785 Implement __iter__ for wxList iterator classes
Some checks failed
ci-build / build-source-dist (push) Has been cancelled
ci-build / Build wxPython documentation (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.9) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.9) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.9) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.10) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.11) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.12) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.13) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.9) (push) Has been cancelled
ci-build / Publish Python distribution to PyPI (push) Has been cancelled
ci-build / Create GitHub Release and upload source (push) Has been cancelled
ci-build / Upload wheels to snapshot-builds on wxpython.org (push) Has been cancelled
This fixes being able to use these classes in for loops, for example.
Specifically it fixes the cmdproc tests with Python 3.13.1.
2025-01-23 21:46:20 -05:00
Edouard Choinière
ff1cae7d56 Add typing annotations to methods returning self. 2025-01-21 21:38:18 -05:00
Scott Talbert
c3092be458 Merge pull request #2468 from lojack5/lojack-typed-typestubs
Some checks failed
ci-build / build-source-dist (push) Failing after 0s
ci-build / build-wheels (x64, macos-13, 3.10) (push) Has been skipped
ci-build / build-wheels (x64, macos-13, 3.11) (push) Has been skipped
ci-build / build-wheels (x64, macos-13, 3.12) (push) Has been skipped
ci-build / build-wheels (x64, macos-13, 3.13) (push) Has been skipped
ci-build / build-wheels (x64, macos-13, 3.9) (push) Has been skipped
ci-build / build-wheels (x64, ubuntu-22.04, 3.10) (push) Has been skipped
ci-build / build-wheels (x64, ubuntu-22.04, 3.11) (push) Has been skipped
ci-build / build-wheels (x64, ubuntu-22.04, 3.12) (push) Has been skipped
ci-build / build-wheels (x64, ubuntu-22.04, 3.13) (push) Has been skipped
ci-build / build-wheels (x64, ubuntu-22.04, 3.9) (push) Has been skipped
ci-build / build-wheels (x64, windows-2022, 3.10) (push) Has been skipped
ci-build / build-wheels (x64, windows-2022, 3.11) (push) Has been skipped
ci-build / build-wheels (x64, windows-2022, 3.12) (push) Has been skipped
ci-build / build-wheels (x64, windows-2022, 3.13) (push) Has been skipped
ci-build / build-wheels (x64, windows-2022, 3.9) (push) Has been skipped
ci-build / build-wheels (x86, windows-2022, 3.10) (push) Has been skipped
ci-build / build-wheels (x86, windows-2022, 3.11) (push) Has been skipped
ci-build / build-wheels (x86, windows-2022, 3.12) (push) Has been skipped
ci-build / build-wheels (x86, windows-2022, 3.13) (push) Has been skipped
ci-build / build-wheels (x86, windows-2022, 3.9) (push) Has been skipped
ci-build / Publish Python distribution to PyPI (push) Has been skipped
ci-build / Create GitHub Release and upload source (push) Has been skipped
ci-build / Upload wheels to snapshot-builds on wxpython.org (push) Has been skipped
ci-build / Build wxPython documentation (push) Has been cancelled
Improve Python type-stubs
2025-01-06 22:14:20 -05:00
DietmarSchwertberger
5279c3c344 add CreateAccessible for Windows only 2024-10-03 14:34:49 +02:00
Scott Talbert
78938da121 Revert CreateAccessible tweaker_tool change for now 2024-05-18 09:26:06 -04:00
Jorge Moraleda
a1c9554bbf Update wxWidgets to v3.2.5. Add support for new, MSW-only Accessibility related methods. 2024-05-17 21:32:22 -04:00
Scott Talbert
2c6307142f Update sip to v6.8.3 and fix deprecations 2024-02-12 23:20:17 -05:00
Scott Talbert
6a049ccc0a Support building with Doxygen 1.9.7
Doxygen 1.9.7 made some changes whereby some method definitions are now
defined in separate XML files, with a "refid" that links to them.  In
order to support this, we need to follow these "refids" to pick up the
method definition from the separate group XML files.
2023-12-05 23:42:21 -05: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