Commit Graph

1 Commits

Author SHA1 Message Date
William S Fulton a0da96aff8 [Python] #3390 Add $pytypename special variable for pytyping typemaps
Finalises the PR keeping the $pytypename mechanism but leaving the default
pytyping SWIGTYPE typemaps as typing.Any. The special variables are exercised
only through explicit typemaps; the default annotation change and the
library-wide pytyping sweep are left for a follow-up.

python.cxx:
- getProxyClassLocalName() uses import_name_string() so a class from an
  imported module gets its fully qualified, package-aware name, as in
  classDeclaration().
- Guard substitutePytypingVars() against a null typemap and skip work when
  there is no special variable to substitute.
- Error when $*pytypename is applied to a non-pointer type instead of
  emitting the literal.
- Remove the _swig_python_version_info >= (3, 5) guards; SWIG supports Python
  3.5 and later, so import typing unconditionally and use a bare
  if typing.TYPE_CHECKING.
- Fix two leaks (SwigType_manglestr, SwigType_typedef_resolve_all).

Doc/Manual/Python.html: correct the feature value pytyping to typing and
document the new special variables with valid HTML.

Tests: python_annotations_typing opts in to proxy-name annotations via explicit
typemaps and covers $*pytypename, class-typed member variables, a class-typed
%constant, and the opaque fallback for a forward-declared class; add
python_annotations_import for the cross-module module-qualified name.

Assisted-by: Claude Code (Opus 4.8)
2026-07-27 23:40:48 +01:00