-
Notifications
You must be signed in to change notification settings - Fork 828
Additional Python 2→3 compatibility fixes for PR #330 #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional Python 2→3 compatibility fixes for PR #330 #344
Conversation
via "prefers-color-scheme". Fixes idank#236
…milar Signed-off-by: Страхиња Радић <contact@strahinja.org>
- Fix iterator protocol: def next() → def __next__() in Peekable class - Fix iterator calls: it.next() → next(it) throughout codebase - Fix map() iterator: yield map() → yield list(map()) in group_continuous - Fix dictionary methods: .iteritems() → .items() in doctests - Fix function names in doctests to match actual definitions - Migrate testing framework: nose → pytest (Python 3.12 compatible) - Update requirements.txt with pytest 8.3.3 and pytest-cov 6.0.0 - Update Makefile to use pytest --doctest-modules These fixes complete the Python 3.12 migration on top of PR idank#330. All 12 tests now passing (100% success rate). Test results: - explainshell/algo/features.py: 1 passed - explainshell/fixer.py: 1 passed - explainshell/manpage.py: 3 passed - explainshell/options.py: 3 passed - explainshell/util.py: 3 passed - explainshell/web/views.py: 1 passed Total: 12 passed in 0.37s Database integration verified with 72,349 documents. Full functionality tested with ls, grep, and tar commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR completes the Python 2→3 migration by fixing iterator protocol methods, updating dictionary operations, and migrating from nose to pytest. The changes enable 100% test compatibility with Python 3.12.
Key Changes:
- Fixed iterator protocol:
def next()→def __next__()andit.next()→next(it) - Updated dictionary methods from
.iteritems()→.items() - Migrated testing framework from nose to pytest
- Fixed map() iterator behavior by wrapping with
list()
Reviewed Changes
Copilot reviewed 46 out of 50 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| explainshell/util.py | Fixed iterator protocol (__next__) and map() wrapping |
| explainshell/web/views.py | Updated iterator calls and function references |
| explainshell/store.py | Changed .iteritems() to .items() |
| explainshell/options.py | Fixed doctests with .items() |
| tests/*.py | Updated assertions from assertEquals to assertEqual |
| Makefile | Changed test command from nosetests to pytest |
| requirements.txt | Replaced nose with pytest (not shown in diffs) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| || 'default'; | ||
|
|
||
| if (!docCookies.getItem(themeCookieName)) { | ||
| var selectedTheme = 'default'; |
Copilot
AI
Oct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable selectedTheme is declared twice, with the second declaration at line 1154 overwriting the theme detection logic from lines 1149-1151. Remove the duplicate declaration and move the assignment inside the if block or remove the if block entirely if the first declaration is sufficient.
| var selectedTheme = 'default'; | |
| selectedTheme = 'default'; |
| # activate logging and redirect all logs to loguru | ||
| logging.basicConfig(handlers=[InterceptHandler()], level=logging.DEBUG, force=True) | ||
|
|
||
| if len(config.HOST_IP) > 1: |
Copilot
AI
Oct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks if config.HOST_IP length is greater than 1, but based on the config file changes, HOST_IP is now set to an empty string by default instead of False. This condition should check for truthiness (non-empty string) rather than length greater than 1. Change to if config.HOST_IP: to properly handle empty string vs valid IP address.
| if len(config.HOST_IP) > 1: | |
| if config.HOST_IP: |
|
Closing this PR - it accidentally included all commits from PR #330. The additional Python 2→3 compatibility fixes have been documented and are available in a separate branch. These fixes (only 5 files changed) are needed on top of PR #330 to achieve 100% Python 3.12 compatibility and test passing rate. I will add a comment on PR #330 with details about these fixes. |
This PR provides additional fixes on top of PR #330 to achieve 100% Python 3.12 compatibility.
Related
Builds upon #330 by @mundanevision20
Summary
These additional Python 2→3 compatibility fixes are needed on top of PR #330 to achieve 100% test passing rate.
Changes
def next()→def __next__()in Peekable classit.next()→next(it)throughout codebaseyield map()→yield list(map())in group_continuous.iteritems()→.items()in doctestsWhy These Fixes Are Needed
impmodule)__next__()in Python 3, notnext()Testing
All 12 tests now passing (100% success rate):
Tested with full database integration (72,349 documents) and verified with commands like
ls -la,grep -r,tar -xzvf.Files Changed
Makefile- Updated test command from nosetests to pytestexplainshell/options.py- Fixed .iteritems() → .items() in doctestsexplainshell/util.py- Fixed iterator protocol and map() iteratorexplainshell/web/views.py- Fixed iterator calls and function namesrequirements.txt- Replaced nose with pytest