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

Remove Python2 #6890

Closed
4 tasks
ulyssessouza opened this issue Sep 9, 2019 · 6 comments · Fixed by #7294 or #7031
Closed
4 tasks

Remove Python2 #6890

ulyssessouza opened this issue Sep 9, 2019 · 6 comments · Fixed by #7294 or #7031
Milestone

Comments

@ulyssessouza
Copy link
Contributor

ulyssessouza commented Sep 9, 2019

Is your feature request related to a problem? Please describe.
As January 1st approaches, support for "Python 2" gets to its end. By deprecating it we can free some machine/time on CI and maybe simplify our "dependency matrix"

Note that this issue is not meant to be executed before the January 1st 2020. The early public issue is just to track it and talk/communicate about.

Describe the solution you'd like

  • Remove py2 from the build matrix in Jenkins
  • Remove Python 2 from setup.py
  • Remove six from requirements.txt
  • Remove the announcement banner in README.md
@funkyfuture
Copy link

two quick remarks:

  1. dropping support for Python 2 also allows to employ language features for better readability, like dict comprehensions, set literals; new-style classes should be used and might provide leverage for further improvements.

  2. why would the support for Python 2.7 be dropped when Python 3.2 and 3.4 is still supported though they reached their eol.

@ulyssessouza
Copy link
Contributor Author

@funkyfuture I agree with the first remark, and for the second, I don't see any problem on dropping that.
The point here is just that dropping 3.2 and 3.4 will just impact the setup.py and not the compose code itself, like removing all the six conditions inside the code that would be a fairly big PR

@chris-crone chris-crone added this to the 1.25.0 milestone Oct 30, 2019
@ulyssessouza ulyssessouza modified the milestones: 1.25.0, 1.26.0 Nov 14, 2019
venthur added a commit to venthur/compose that referenced this issue Nov 19, 2019
Closes: docker#6890

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>
ndeloof added a commit to ndeloof/compose that referenced this issue Nov 19, 2019
see docker#6890

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ndeloof added a commit that referenced this issue Nov 20, 2019
see #6890

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ndeloof pushed a commit to venthur/compose that referenced this issue Nov 20, 2019
Closes: docker#6890

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>
@ulyssessouza ulyssessouza changed the title Deprecate Python2 Remove Python2 Nov 21, 2019
@agronholm
Copy link

dropping support for Python 2 also allows to employ language features for better readability, like dict comprehensions, set literals; new-style classes should be used and might provide leverage for further improvements.

I'm not arguing against dropping Python 2 support, but all of these language features are already supported on Python 2.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 30, 2019

There's probably many places a pure python 3 codebase could offer improvements, but my main motivation here is to reduce the maintenance effort.

@SuperSandro2000
Copy link

and Python 2.7 is EOL and is going to be removed from the next Debian and Ubuntu releases.

ndeloof added a commit that referenced this issue Dec 6, 2019
see #6890

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ndeloof added a commit that referenced this issue Jan 8, 2020
see #6890

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ndeloof added a commit that referenced this issue Jan 8, 2020
see #6890

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@DeeDeeG
Copy link

DeeDeeG commented Mar 5, 2020

Hi,

Remove the announcement banner in README.md

I think it could be worthwhile to leave this as a deprecation notice for some time after the change, so folks with broken python support who come here can know what's up (that this is intentional, etc.)

Otherwise all sounds reasonable to me. 👍

Edit: Or you could pin this issue. Just something to avoid issue spam and to give clarity to the situation.

Edit 2:

Python 2.7 is EOL and is going to be removed from the next Debian and Ubuntu releases.

Not strictly true. The executable named python is being removed, by default, from fresh installs of Ubuntu, but upgrades of prior distros are planned to have python2 still installed as the default Python. It is also runnable (for upgrades from earlier Ubuntu versions) as python, via a symlink. But for fresh Focal installs, one needs to run python2 or python3 explicitly, and there is no program named exactly "python".

See:

alex-ubitec pushed a commit to alex-ubitec/compose that referenced this issue Mar 11, 2020
----

Downgrade gitpython to 2.1.15 and idna to 2.8

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>

Removed Python2 support

Closes: docker#6890

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>

Removed six

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>
alex-ubitec pushed a commit to alex-ubitec/compose that referenced this issue Mar 11, 2020
----

Downgrade gitpython to 2.1.15 and idna to 2.8

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>

Removed Python2 support

Closes: docker#6890

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>

Removed six

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>

Removed now useless check for version_info >= 2.7

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>

Removed now unused get_output_stream method

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>

Import unittest.mock directly.

We don't need to support Python2 anymore.

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>
alex-ubitec pushed a commit to alex-ubitec/compose that referenced this issue Mar 11, 2020
----

Downgrade gitpython to 2.1.15 and idna to 2.8

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>

Removed Python2 support

Closes: docker#6890

- Removed six
- Removed now useless check for version_info >= 2.7
- Removed now unused get_output_stream method
- Import unittest.mock directly.

How we removed six from docker-compose

We expect this to happen in a couple steps,

1. Remove six entirely, and remove python2.7 from requirements, setup, etc.
2. cleanup code that is left (All the conditionals that are now always True or False)
3. Remove all unnecessary `__future__` commands, by modifying the pre-commit-hook of python sourts to be `--py3-plus`

After removing all occurrances, we made sure `six` wasn't used anymore running a search for

```txt
six\.\w+\(([^()]+)\)
```
- We replaced all types for their corresponding python3 types. Note how
  six returns a tuple for the isinstance (since in python2 there are
  more than one type, but that isn't necessary in python3, so we removed
  the tuple and instead used the class directly)

We then searched for all instances where code could be pruned. (i.e., if/else clauses that now where always `True` or `False`)

After that,

- Removed inheritinng from `object` super class, it isn't necessary in python3
- `# coding ... utf-8` statements are not needed
- `super(ClassName, self)` can now be replaced with `super()`
alex-ubitec pushed a commit to alex-ubitec/compose that referenced this issue Mar 12, 2020
----

Removed Python2 support

Closes: docker#6890

- Removed six
- Removed now useless check for version_info >= 2.7
- Removed now unused get_output_stream method
- Import unittest.mock directly.

How we removed six from docker-compose

We expect this to happen in a couple steps,

1. Remove six entirely, and remove python2.7 from requirements, setup, etc.
2. cleanup code that is left (All the conditionals that are now always True or False)
3. Remove all unnecessary `__future__` commands, by modifying the pre-commit-hook of python sourts to be `--py3-plus`

After removing all occurrances, we made sure `six` wasn't used anymore running a search for

```txt
six\.\w+\(([^()]+)\)
```
- We replaced all types for their corresponding python3 types. Note how
  six returns a tuple for the isinstance (since in python2 there are
  more than one type, but that isn't necessary in python3, so we removed
  the tuple and instead used the class directly)

We then searched for all instances where code could be pruned. (i.e., if/else clauses that now where always `True` or `False`)

After that,

- Removed inheritinng from `object` super class, it isn't necessary in python3
- `# coding ... utf-8` statements are not needed
- `super(ClassName, self)` can now be replaced with `super()`

Signed-off-by: Alejandro G. Recuenco <alejandrogonzalezrecuenco@gmail.com>
alexrecuenco pushed a commit to alexrecuenco/compose that referenced this issue Mar 14, 2020
----

Removed Python2 support

Closes: docker#6890

- Removed six
- Removed now useless check for version_info >= 2.7
- Removed now unused get_output_stream method
- Import unittest.mock directly.

How we removed six from docker-compose

We expect this to happen in a couple steps,

1. Remove six entirely, and remove python2.7 from requirements, setup, etc.
2. cleanup code that is left (All the conditionals that are now always True or False)
3. Remove all unnecessary `__future__` commands, by modifying the pre-commit-hook of python sourts to be `--py3-plus`

After removing all occurrances, we made sure `six` wasn't used anymore running a search for

```txt
six\.\w+\(([^()]+)\)
```
- We replaced all types for their corresponding python3 types. Note how
  six returns a tuple for the isinstance (since in python2 there are
  more than one type, but that isn't necessary in python3, so we removed
  the tuple and instead used the class directly)

We then searched for all instances where code could be pruned. (i.e., if/else clauses that now where always `True` or `False`)

After that,

- Removed inheritinng from `object` super class, it isn't necessary in python3
- `# coding ... utf-8` statements are not needed
- `super(ClassName, self)` can now be replaced with `super()`

Signed-off-by: alexrecuenco <alejandrogonzalezrecuenco@gmail.com>
alexrecuenco pushed a commit to alexrecuenco/compose that referenced this issue Mar 14, 2020
----

Removed Python2 support

Closes: docker#6890

- Removed six
- Removed now useless check for version_info >= 2.7
- Removed now unused get_output_stream method
- Import unittest.mock directly.

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
venthur added a commit to venthur/compose that referenced this issue Jun 3, 2020
Closes: docker#6890

Signed-off-by: Bastian Venthur <bastian.venthur@flixbus.com>
alexrecuenco pushed a commit to alexrecuenco/compose that referenced this issue Jun 18, 2020
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>
alexrecuenco added a commit to alexrecuenco/compose that referenced this issue Jun 18, 2020
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>
alexrecuenco added a commit to alexrecuenco/compose that referenced this issue Jun 18, 2020
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>
alexrecuenco added a commit to alexrecuenco/compose that referenced this issue Jun 18, 2020
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>
alexrecuenco added a commit to alexrecuenco/compose that referenced this issue Aug 5, 2020
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>
alexrecuenco added a commit to alexrecuenco/compose that referenced this issue Aug 10, 2020
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>
alexrecuenco added a commit to alexrecuenco/compose that referenced this issue Aug 11, 2020
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>
aiordache pushed a commit that referenced this issue Aug 21, 2020
Closes: #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>
ulyssessouza pushed a commit that referenced this issue Aug 21, 2020
Closes: #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>
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 a pull request may close this issue.

7 participants