Conversation
Moved and refactored bot edit permission logic from botEdit.py into a new 'bot_edit' package with modular files for template and time-based checks. Introduced EditPermissionChecker class in bot_edit/__init__.py for instance-based permission checking. Updated imports and usage in botEdit.py to use the new structure. Also changed logger.info to logger.error for error reporting in several files for better log level semantics.
Replaces txtlib with wikitextparser for extracting templates and parameters in bot_edit_by_templates.py. Updates logic to use wikitextparser's API and improves logging messages for template handling.
Introduces comprehensive unit tests for the is_bot_edit_allowed function, covering bypass conditions, template restrictions (nobots, bots, custom templates), bot job types, caching behavior, parameter combinations, edge cases, and Arabic-specific stop templates. Also refactors imports in bot_edit/__init__.py, txtlib.py, and edit_validator.py for consistency.
Migrated and refactored unit tests for is_bot_edit_allowed to use pytest, added fixtures for environment and template mocking, and split command-line bypass tests into a separate file. Improved coverage for template handling, cache behavior, and edge cases. Deprecated sys.argv-based bypass tests with a skip marker.
Moved template-related bot_edit tests into a dedicated subdirectory for better organization. Added a new test file stub for bot_edit_by_time, preparing for future time-based test implementations.
Cleaned up the data.py file by removing large blocks of commented-out docstrings and unused code related to data class attributes. This improves readability and maintainability without affecting functionality.
Enable optional file logging in setup_logging by adding a log_file parameter. Introduce prepare_log_file to create parent directories (using pathlib.expanduser) and handle errors. When log_file is provided, add a UTF-8 FileHandler for general logs and a separate .err FileHandler that captures WARNING and above. Also refactor console handler naming, preserve colored console formatting, change default logger name to "mw_api", and accept numeric logging levels as well as string names.
Replace fragile warn logs with full exception logging: change logger.warning(e) to logger.exception('Exception:', exc_info=True) across mw_api/super/bot.py and mw_api/super/bot_new.py to capture stack traces. Add an internal showDiff implementation in mw_api/api_utils/ask_bot.py (using difflib and logger) and replace calls to printe.showDiff. Remove obsolete mw_api/tt.py. These changes improve diagnostics and simplify diff handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.