llimllib / limbo

A simple, clean, easy to modify Slack chatbot
MIT License
402 stars 160 forks source link

Proposition: Drop support for Python 2 #161

Closed eSoares closed 4 years ago

eSoares commented 5 years ago

Currently limbo supports Python 2 and Python 3. I am writing this issue to kick a discussion of dropping support for Python 2 and welcome Python 3 improvements.

As anyone who tried to develop plugins or contribute to the project have found, keeping the support for both version, adds some extra work and keeps improvements of the language out of the project.

In particular, the main areas that could improve if Python 2 support is dropped are:

Some may argue that keeping Python 2 support is cost free, but I disagree. Keeping Python 2 also keeps new language features out of the project. And worst, makes the project harder to maintain and contribute, because all code needs to run with the kirks of each version.

In addition to that, Python 2 is going to stop being officially supported in 2020: https://pythonclock.org So even if currently there are users of limbo that use it in Python 2, they should start move soon to Python 3.

hugovk commented 5 years ago

See https://python3statement.org for a list of projects which have pledged to drop support for Python 2 on or before it's EOL on 2020-01-01.

And pyupgrade is a useful tool to help upgrade Python syntax for newer language versions.

llimllib commented 5 years ago

Thankfully, the syntax is already compatible with python 3; this would be a matter of dropping support for python 2. It would indeed be very nice to switch to f-strings, but I don't think there's a whole lot to gain otherwise?

Addition of typing that could easy the coding of plugins and new functionality;

I do think we could stand to add some type notes for sure, but we could do that in a python 2.7 compatible way if we wanted to. (I think? I just kind of vaguely recall that either 2.7 supports the syntax, or is it that you have to use a weird comment-type syntax?)

Maybe asyncio can also improve somethings?

I've actually played around with an asyncio branch, and I found asyncio to be a confusing mess.

It actually kind of makes me want to convert limbo to go tbh, but I'm much too lazy to do that.

If somebody else wants to make an asyncio branch that works, I'm all ears.

Maybe other niceties that I have forgot (iterators everywhere, Enums,...)

This is the crux of the matter, I think; it's not much pain to support both python 2.7 and python 3 ATM.

So I'm open to it but don't feel like python 2.7 support is really dragging me down? Mostly it makes me use ugly format strings.

That said, I'm python 3 all the way, so if you can convince me that there's real value to be gained I'll be happy to mark a revision as the last one that supports python 2.7 and move forward with 3 only.

StewPoll commented 5 years ago

Ultimately, you'll want/need to drop python 2.7 eventually. With Django and other larger frameworks already having dropped support, it will hasten the rest of the community to do so as well.

Why not get it done now? All it really should need is simply removing python 2.7 from travis, and telling people to run it in python 3 instead.

llimllib commented 5 years ago

I will want to drop python 2.7 eventually for sure, I don't see who I benefit by dropping it today, you know?

hugovk commented 5 years ago

Just as an example, here's what it could look like after removing a few things manually (like 2.7 Travis) and then running pyupgrade:

llimllib commented 5 years ago

right, it changes the things I expected (I put in all the things that keep it compatible, so it's no surprise haha). Basically f-strings would be nicer plus it removes the one utility function that does python2/3 string handling, and I can remove the makefile switch.

Still doesn't seem like that big a win to me?

llimllib commented 5 years ago

All the {0}s btw are because I used to support python 2.6, because it was the standard RH python for a long time, now that was a PITA I dropped as soon as possible

hugovk commented 5 years ago

I've split the commits, https://github.com/llimllib/limbo/commit/4448a8d7d6c4ea4a8287ce067a78f3978e41befa is a 2.6 -> 2.7 upgrade, and https://github.com/llimllib/limbo/commit/f0a2d2ea8c3e89d8d687fe39fdddd3900e91a621 is 2.7 -> 3.4+.

eSoares commented 5 years ago

I will want to drop python 2.7 eventually for sure, I don't see who I benefit by dropping it today, you know?

We could argue this till 2.7 reaches EOL, but do we really want to keep being stuck in 2.7?

I do think we could stand to add some type notes for sure, but we could do that in a python 2.7 compatible way if we wanted to. (I think? I just kind of vaguely recall that either 2.7 supports the syntax, or is it that you have to use a weird comment-type syntax?)

We could add some weird comment syntax yes, but I think some tools will maybe miss it or not work as good as typings from python 3.

Let's do a modest proposal and wait a couple of weeks to see if anyone manifests interest? In order to increase the reachability of this matter to limbo users, maybe merge this warning: https://github.com/eSoares/limbo/commit/b755e9d3a8bcfbbb8e8eadc22e5795352aad7609

eSoares commented 4 years ago

Closed by #186