Clean up python2 style code by alexrecuenco · Pull Request #7294 · docker/compose · GitHub
Skip to content

Clean up python2 style code - #7294

Merged
aiordache merged 2 commits into
docker:masterfrom
alexrecuenco:remove-python2-1.26goal
Aug 11, 2020
Merged

aiordache merged 2 commits into
docker:masterfrom
alexrecuenco:remove-python2-1.26goal

Conversation

@alexrecuenco

@alexrecuenco alexrecuenco commented Mar 14, 2020 •

Copy link
Copy Markdown

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
Copy Markdown
Author

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

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Author

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

@alexrecuenco
alexrecuenco force-pushed the remove-python2-1.26goal branch from 3ddcc25 to ec66c1b Compare June 18, 2020 06:37
@alexrecuenco
alexrecuenco force-pushed the remove-python2-1.26goal branch from ec66c1b to 8f7d7d1 Compare August 5, 2020 23:17
@ulyssessouza

ulyssessouza commented Aug 10, 2020 •

Copy link
Copy Markdown
Contributor

@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 force-pushed the remove-python2-1.26goal branch from 8f7d7d1 to db01591 Compare August 10, 2020 10:17
@alexrecuenco alexrecuenco changed the title Remove python2 1.26goal Clean up python2 style code Aug 10, 2020
@alexrecuenco

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

Comment thread setup.py Outdated
Comment thread setup.py Outdated
@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
alexrecuenco force-pushed the remove-python2-1.26goal branch from 7076d7f to 46624ce Compare August 11, 2020 10:45
@alexrecuenco

Copy link
Copy Markdown
Author

@aiordache aiordache left a comment

Copy link
Copy Markdown
Contributor

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