anoexpected added a comment.
@Xqt I have started analyzing the codebase for this refactor.
Since from __future__ import annotations is imported at the top of config.py,
__annotations__ will store types as strings (e.g., 'int | float') rather than
actual type objects.
My proposed plan:
Standardize: Explicitly add the type hint to socket_timeout (currently
tuple | int | float) so we can remove its hardcoded exception block.
Resolve: In _check_user_config_types, I will iterate through
globals()['__annotations__'].
Parse: I plan to implement a lightweight resolution logic to convert the
annotation strings back to types:
Split Unions by |.
Strip generic subscripts (e.g., treat dict[str, str] as just dict for
runtime checking) to avoid complex parsing of nested types.
Resolve the names using globals() (for imported types) and builtins
(for int, str, etc.).
Does this approach regarding stripping generics and manual string resolution
align with your expectations, or is there an existing internal utility I should
use instead?
TASK DETAIL
https://phabricator.wikimedia.org/T416145
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]