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

Clean up python2 style code #7294

Merged
merged 2 commits into from
Aug 11, 2020

Conversation

alexrecuenco
Copy link

@alexrecuenco alexrecuenco commented Mar 14, 2020

This branch works on top of the PR by @venthur rebasing the branch on top of 1.26.x

  • It removes support for python2, and early versions of python3 (<3.5). I am not sure if I left some requirements somewhere, I would appreciate if someone can make sure that is the case.
  • As recommended by @graingert, I added pyupgrade to the pre-commit hooks to allow an easier transition for developers used to python2.

NOT NOTE: The only change to code-style when transferring to python3 I am not sure if people would agree is the change from lambda c: c.name to the more modern use of the operator module with attrgetter('name')

Closes: #6890
Resolves #6890

Signed-off-by: alexrecuenco alejandrogonzalezrecuenco@gmail.com

@alexrecuenco alexrecuenco force-pushed the remove-python2-1.26goal branch 2 times, most recently from 861d194 to 2a813c8 Compare March 14, 2020 11:59
@alexrecuenco
Copy link
Author

Note that, as mentioned by @ulyssessouza (here), we won't be merging on master,

to sync that with the next Ubuntu release

That is why I thought it would be appropriate to merge on top of 1.26.x, since this is a 1.26.x Goal anyway.

@alexrecuenco alexrecuenco marked this pull request as ready for review March 14, 2020 15:11
@ulyssessouza
Copy link
Collaborator

@alexrecuenco Could you please rebase so that we can include it in the next RC?

@alexrecuenco alexrecuenco force-pushed the remove-python2-1.26goal branch 3 times, most recently from c1dfb0b to 3ddcc25 Compare June 18, 2020 05:37
@alexrecuenco
Copy link
Author

Do you mean to rebase on master? Or on 1.26.x

@ulyssessouza
Copy link
Collaborator

ulyssessouza commented Aug 10, 2020

@alexrecuenco Rebase with from master, pls.

By the way, the removal of python2 was already merged in another PR.
So please rename that to something like Refactor or Clean up of the previous removal

@alexrecuenco alexrecuenco changed the title Remove python2 1.26goal Clean up python2 style code Aug 10, 2020
@alexrecuenco
Copy link
Author

I don't think I can rename the branch, for that I would need to make a new PR, let me know if you prefer that.

Other than that, it should be rebased now.

@ulyssessouza
Copy link
Collaborator

The renaming was just for the title of the PR. The branch name has no impact

setup.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@alexrecuenco alexrecuenco force-pushed the remove-python2-1.26goal branch 2 times, most recently from 1357f25 to 7076d7f Compare August 11, 2020 10:41
Closes: docker#6890

Some remarks,

- `# coding ... utf-8` statements are not needed
- isdigit on strings instead of a try-catch.
- Default opening mode is read, so we can do `open()` without the `'r'` everywhere
- Removed inheritinng from `object` class, it isn't necessary in python3.
- `super(ClassName, self)` can now be replaced with `super()`
- Use of itertools and `chain` on a couple places dealing with sets.
- Used the operator module instead of lambdas when warranted
    `itemgetter(0)` instead of `lambda x: x[0]`
    `attrgetter('name')` instead of `lambda x: x.name`
- `sorted` returns a list, so no need to use `list(sorted(...))`
- Removed `dict()` using dictionary comprehensions whenever possible
- Attempted to remove python3.2 support

Signed-off-by: alexrecuenco <alejandrogonzalezrecuenco@gmail.com>
Removed unused versions, (we only support python3.4 onwards)

Signed-off-by: alexrecuenco <alejandrogonzalezrecuenco@gmail.com>
@alexrecuenco
Copy link
Author

Thank you, I added your suggestion and rebased again on docker/master.

Copy link
Contributor

@aiordache aiordache left a comment

Choose a reason for hiding this comment

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

LGTM!

@aiordache aiordache merged commit b01601a into docker:master Aug 11, 2020
@alexrecuenco alexrecuenco deleted the remove-python2-1.26goal branch August 11, 2020 12:20
@alexrecuenco alexrecuenco restored the remove-python2-1.26goal branch August 11, 2020 12:20
@alexrecuenco alexrecuenco deleted the remove-python2-1.26goal branch August 11, 2020 12:20
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.

Remove Python2
3 participants