Commit Graph

5 Commits

Author SHA1 Message Date
William S Fulton 7a137da8f3 [Python] Check annotations in .pyi stubs with -builtin and -fastproxy
The annotation tests skipped their checks with -builtin or -fastproxy as
neither adds __annotations__ to the generated runtime objects. That is no
longer a reason to skip when -pyi is also used, as the annotations are then
in the generated stub file, but the stub lookup only worked for -builtin.

With -fastproxy a method is the flat C wrapper function, so its __qualname__
is Class_method instead of Class.method. Pass a fastproxy flag from each
runme down to the stub lookup so that such a name is split on the stub class
names only when it really is a flat name. Reword the comment explaining when
annotations_supported is false, which was misleading with -pyi.

Assisted-by: Claude Code (Opus 5)
2026-08-04 23:41:57 +01:00
William S Fulton f06d86749c [Python] Fix empty classes and imported bases in .pyi files
A generated stub class with no wrapped members had an empty suite, which
is invalid Python syntax. Stubs could also refer to base classes from
%imported modules without importing the corresponding Python proxy
module, leaving those names unresolved.

Track whether each stub class emits a member and use an ellipsis when
its body would otherwise be empty. Collect modules referenced through
%import and emit them before declarations, using the same package and
relative import rules as the generated Python proxy.

Keep annotation tests active with -pyi by parsing annotations from the
generated stub instead of expecting them on runtime objects. Include
each generated .pyi file in multi-module Pyrefly checks.

Add Python 3.14 Linux CI configurations for -pyi -typehints with and
without -builtin.

See #3473.

Assisted-by: Codex (GPT-5.6 Sol)
2026-08-04 23:41:57 +01:00
Julien Schueller cb6e7c542a Python: Drop sys.version_info<3 examples code 2026-07-06 23:50:30 +01:00
William S Fulton 2abbb26050 Remove two python asserts which should not be in test-suite 2025-08-08 19:37:35 +01:00
Guido Imperiale 9fa16da77a
Python: SWIG_AsArgcArgv thread safety (#3230)
* Make SWIG_AsArgcArgv thread-safe in free-threading Python.
* Fix memory leak in case of invalid inputs, with and without GIL. e.g. mainv(["foo", 1]) raises TypeError; previously it would leak both a char *[3] and a char * for "foo".
* Improve test coverage.
* Add swig_test_utils.py to provide some useful testing utilities.
2025-08-08 18:38:07 +01:00