Skip to content

fix: restore pywikibot config access through wrapper import#81

Merged
DaxServer merged 1 commit intomainfrom
fix/pwb-config-wrapper
Apr 3, 2026
Merged

fix: restore pywikibot config access through wrapper import#81
DaxServer merged 1 commit intomainfrom
fix/pwb-config-wrapper

Conversation

@DaxServer
Copy link
Copy Markdown
Owner

PR #77 replaced pwb.config (from pywikibot.scripts.wrapper) with pywikibot.config to 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.config and documents the constraint in CLAUDE.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
- 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`).

@DaxServer DaxServer merged commit 3d44fe6 into main Apr 3, 2026
4 checks passed
@DaxServer DaxServer deleted the fix/pwb-config-wrapper branch April 3, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant