Phase 1 Refactoring: Replace sys.argv coupling and global state with DI#1
Phase 1 Refactoring: Replace sys.argv coupling and global state with DI#1
Conversation
…pling Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
|
@copilot complete all remaining phases |
Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
All phases (1-4) are now complete in commits Phase 1 (Foundation): Phase 2 (Decomposition):
Phase 3 (Error Handling): Typed exception hierarchy ( Phase 4 (Modernization): Type hints added to key files, 60 tests passing, 0 security alerts. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot write pytest tests for each one code files |
Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
Added comprehensive pytest tests for all new modules in commit New test files:
Total: 123 tests passing (including previously added tests for Phase 1-3 modules) Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@copilot Tests required network connection should be mocked using monkey patch |
Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
Fixed in commit Changes made:
All 123 tests pass with no network access required. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot create pytest.yaml action to run tests when PR is open to branch main only |
Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
Created in commit Configuration:
|
|
@copilot why we still use sys.argv in code not in config (if print_test[1] or "printdata" in sys.argv:)? |
Co-authored-by: MrIbrahem <26301308+MrIbrahem@users.noreply.github.com>
Fixed in commit
Now 0 occurrences of Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Refactoring Progress - All Phases Complete ✅
Phase 1: Foundation ✅ COMPLETE
mw_api/core/config.pywithBotConfigdataclassmw_api/core/container.pywithSessionManagerclassmw_api/api_utils/botEdit.pyto useBotConfigmw_api/super/super_login.pyto useBotConfigmw_api/super/bot.pyto useSessionManagermw_api/super/login_wrap.pyto refactor globalhasesFiles Updated to Remove sys.argv
mw_api/api_utils/printe.py- Replacedsys.argvchecks withget_default_config()mw_api/api_utils/ask_bot.py- Replacedsys.argvchecks withconfigoptionsmw_api/super/cookies_bot.py- Replacednocookiescheck withconfig.no_cookiesmw_api/super/bot_new.py- Replacednologin,dopost,raisechecks with configmw_api/super/Login_db/bot.py- Replacedtestcheck withconfig.test_modemw_api/super/params_help.py- Replacedibrahemsummary,nologinchecksmw_api/super/S_Category/catdepth_new.py- Replacedprintresultcheckmw_api/super/S_Page/super_page.py- Replacedprintdata,printpopchecksNew BotConfig Options Added
no_login: Disable login (replaces 'nologin')no_cookies: Disable cookie persistence (replaces 'nocookies')no_print: Disable printing (replaces 'noprint')no_diff: Disable diff output (replaces 'nodiff')show_diff: Force show diff (replaces 'diff')ask_mode: Enable interactive ask mode (replaces 'ask')debug_logging: Enable debug logging (replaces 'debug')warning_logging: Enable warning logging (replaces 'warning')test_print: Enable test print output (replaces 'test_print')print_pop: Enable print pop output (replaces 'printpop')print_result: Enable print result output (replaces 'printresult')Testing ✅ COMPLETE - 123 tests passing
All tests pass with fully mocked network calls.
Summary
sys.argvfor logic control (only documentation comments remain)BotConfigdataclassOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.