fix: restore pywikibot config access through wrapper import#81
fix: restore pywikibot config access through wrapper import#81
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the pywikibot configuration access to use the pywikibot.scripts.wrapper module, ensuring proper initialization as documented in the updated CLAUDE.md constraints. Review feedback identifies a likely incorrect import syntax in src/wikibots/lib/bot.py and suggests improving documentation clarity in CLAUDE.md by applying backticks to tool names and exit codes.
| from pywikibot.data.api import Request | ||
| from pywikibot.page import BasePage | ||
| from pywikibot.page._collections import ClaimCollection | ||
| from pywikibot.scripts.wrapper import pwb |
There was a problem hiding this comment.
The import statement from pywikibot.scripts.wrapper import pwb is likely incorrect. In standard pywikibot installations, wrapper is a module (the pwb.py script) and does not contain an object or submodule named pwb. To import the wrapper module and alias it as pwb (which allows accessing pwb.config as intended), you should use the import ... as ... syntax.
| from pywikibot.scripts.wrapper import pwb | |
| import pywikibot.scripts.wrapper as pwb |
| ### Constraints | ||
|
|
||
| - `redis` must stay on `<6.0.0` — Toolforge runs Redis server 6.0.16, and redis-py 7.x requires Redis 7.2+. | ||
| - pywikibot config is accessed via `pwb.config` where `pwb` is imported from `pywikibot.scripts.wrapper`. Importing through the wrapper triggers proper pywikibot initialization — using `pywikibot.config` directly does not work. The ty `possibly-missing-submodule` warnings on `pwb.config` are expected (exit 0). |
There was a problem hiding this comment.
The reference to the ty tool is missing backticks, which makes it look like a typo for 'the' or 'type'. Adding backticks clarifies that it refers to the command-line tool defined in the 'Commands' section of this document. Additionally, backticking exit 0 improves readability as it refers to a process exit code.
| - pywikibot config is accessed via `pwb.config` where `pwb` is imported from `pywikibot.scripts.wrapper`. Importing through the wrapper triggers proper pywikibot initialization — using `pywikibot.config` directly does not work. The ty `possibly-missing-submodule` warnings on `pwb.config` are expected (exit 0). | |
| - pywikibot config is accessed via `pwb.config` where `pwb` is imported from `pywikibot.scripts.wrapper`. Importing through the wrapper triggers proper pywikibot initialization — using `pywikibot.config` directly does not work. The `ty` `possibly-missing-submodule` warnings on `pwb.config` are expected (`exit 0`). |
PR #77 replaced
pwb.config(frompywikibot.scripts.wrapper) withpywikibot.configto fix type errors. However, the wrapper import is required for proper pywikibot initialization — without it, config settings (auth tokens, throttle) don't take effect.This reverts the config access pattern to use
pwb.configand documents the constraint in CLAUDE.md.