Skip to content
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

PR: Drop Python 2 #251

Merged
merged 8 commits into from
Oct 15, 2021
Merged

PR: Drop Python 2 #251

merged 8 commits into from
Oct 15, 2021

Conversation

dalthviz
Copy link
Member

Fixes #250

@dalthviz dalthviz added this to the v2.0.0 milestone Sep 29, 2021
@dalthviz dalthviz self-assigned this Sep 29, 2021
Copy link
Contributor

@avalentino avalentino left a comment

Choose a reason for hiding this comment

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

Python 2.7 is also mentioned in a comment in qtpy/tests/test_qtpositioning.py.

setup.py Outdated Show resolved Hide resolved
@dalthviz dalthviz force-pushed the fix_issue_250 branch 10 times, most recently from 6590ed4 to b4821e7 Compare October 5, 2021 16:42
@dalthviz dalthviz changed the title [WIP] PR: Drop Python 2 PR: Drop Python 2 Oct 5, 2021
Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

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

Very thorough job, @dalthviz ! I ran a bunch of regexes I use to detect possible Py <3.6 blocks and code, as well as manually looked through both your changes and the codebase, and everything looked great. I also ran pyupgrade on the repo with pyupgrade --py36-plus setup.py qtpy/*.py qtpy/tests/*.py qtpy/_patch/*.py, which did spot and autofix a few remaining issues that allowed eliminating/simplifying a further >100 lines of code:

  • Legacy absolute_import future imports that were missed in the tests
  • Calls to the mock third-party backport instead of the built-in unittest.mock, which allowed eliminating it as an extra test dependency
  • Redundant coding: utf-8 declarations (since the default source file encoding on Python 3+ is UTF-8)
  • A few uses of legacy ordered format() calls that could be safety rewritten as much simpler f-strings
  • A few other small odds and ends (a legacy super() call, a legacy class declaration, and importing and using io.open() instead of the now-identical and more concise/standard builtin open()

The results of the run plus the accompanying manual tweaks (removing the now-unused import io and dropping mock from the test scripts) are on the fix_issue_250 branch on my fork. Assuming you agree with the changes, feel free to pull that and push here, or I can do so directly if that's easier.

@dalthviz
Copy link
Member Author

Hi @CAM-Gerlach thank you for checking and futher helping with this! I will check the new changes and pull them here 👍

@CAM-Gerlach
Copy link
Member

I assume the CI issues are a result of rebasing on #225 , as I didn't see anything obviously connected to my changes.

However, just in case you didn't already see it, in test-pyside6.sh a dead elif block for Python 2.7 got added, aside from a couple of trivial things (coding marker in QtWebEngine.py, old-style format in pytest_report_header in conftest.py),

CAM-Gerlach
CAM-Gerlach previously approved these changes Oct 13, 2021
Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

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

LGTM @dalthviz ; thanks as always for all your hard work

Update RELEASE instructions too
Remove py3compat module
Remove sys.version based validations
@dalthviz
Copy link
Member Author

dalthviz commented Oct 15, 2021

Hi @CAM-Gerlach , could you do a new review here to check if after the last rebase everything is still good? Thanks!

Edit: Also, if is good go ahead and merge it 👍

@CAM-Gerlach
Copy link
Member

Sure, in work 👍

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

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

Thanks so much for all your work here, @dalthviz . I reviewed all the code changes, regexed for any remaining vestiges of Qt4/Python 2, and re-ran pyupgrade, and everything looks good aside from two issues. Since GitHub wouldn't let me make one of them as a suggestion, I just made them as separate commits (for ease of cherry-picking/dropping/fixuping etc) on my branch, like before, so if you like, you can easily just pull that in again and cherry-pick/squash/fixup/etc. to your liking if you agree with the changes, or if you decline the one I couldn't make as a suggestion, feel free to just apply the suggestion here.

Specifically, in addition to the comment about mock, not sure if it happened in the rebase, but most of lines 89-102 in _qfiledialog_wrapper() in compat.py appear to be dead code due to being only for Qt <=4.6, and can be replaced by just:

    result = func(parent, caption, basedir, filters, selectedfilter, options)
    if sys.platform == "win32":
        # On Windows platforms: restore standard outputs
        sys.stdout, sys.stderr = _temp1, _temp2

(See a1380d7)

.github/workflows/test-pyside6.sh Outdated Show resolved Hide resolved
@CAM-Gerlach CAM-Gerlach dismissed their stale review October 15, 2021 17:12

Out of date after rebase

@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented Oct 15, 2021

Oops, forgot to force push to the branch on my fork, sorry. Its up to date now; specifically a1380d7 is the commit with the Qt4 dead code cleanup that might have been missed during the rebase.

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

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

LGTM, thanks so much @dalthviz

@CAM-Gerlach CAM-Gerlach merged commit cc9086e into spyder-ide:master Oct 15, 2021
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.

Drop Python 2 support
3 participants