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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

All in on Python 3 #619

Open
wants to merge 25 commits into
base: schematics3
Choose a base branch
from
Open

All in on Python 3 #619

wants to merge 25 commits into from

Conversation

kstrauser
Copy link
Contributor

Hi gang! It's been a while!

Python 2 is dead and Python 3 is the present. This PR removes Python 2 compatibility and starts adopting Python 3 features. It:

  • Updates tox to use currently supported versions of Python
  • Removes compat.py
  • Switches to Python 3-style classes (i.e. class Foo: instead of class Foo(object):)
  • Removes all __future__ imports (the future is here!)
  • Removes deprecated.py (as long as we're breaking things...)
  • Uses the new "bare" super() syntax
  • Adds just a few pylint and isort cleanups (more to follow in a separate PR)
  • Mentions that I've contributed a line or two from time to time 馃槈
  • Whenever reasonable, switches to f-strings (but I wasn't a purist about it)

These are breaking changes, and I think this would have to go into a new release: Schematics 3. That's a happy semantic versioning coincidence, isn't it?

There are some other things I'd like to do before we'd consider cutting a new release, but this PR is big enough as it is so I'll put those in other PRs.

@codecov-io
Copy link

codecov-io commented Apr 3, 2021

Codecov Report

Merging #619 (80d2fb7) into schematics3 (90dee53) will increase coverage by 1.91%.
The diff coverage is 93.61%.

Impacted file tree graph

@@               Coverage Diff               @@
##           schematics3     #619      +/-   ##
===============================================
+ Coverage        91.06%   92.98%   +1.91%     
===============================================
  Files               24       22       -2     
  Lines             2541     2309     -232     
===============================================
- Hits              2314     2147     -167     
+ Misses             227      162      -65     
Impacted Files Coverage 螖
schematics/common.py 100.00% <酶> (+7.14%) 猬嗭笍
schematics/contrib/mongo.py 100.00% <酶> (+4.34%) 猬嗭笍
schematics/types/serializable.py 92.59% <50.00%> (+1.36%) 猬嗭笍
schematics/iteration.py 91.66% <80.00%> (+5.55%) 猬嗭笍
schematics/util.py 91.35% <80.00%> (+6.41%) 猬嗭笍
schematics/exceptions.py 96.85% <87.50%> (+2.56%) 猬嗭笍
schematics/models.py 97.84% <96.29%> (-0.04%) 猬囷笍
schematics/__init__.py 100.00% <100.00%> (酶)
schematics/contrib/enum_type.py 97.36% <100.00%> (+4.34%) 猬嗭笍
schematics/contrib/machine.py 85.71% <100.00%> (酶)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 90dee53...80d2fb7. Read the comment docs.

This was referenced Apr 3, 2021
@Mizaro
Copy link

Mizaro commented Apr 9, 2021

Do you think this project can stay python2 compatible?

@kstrauser
Copy link
Contributor Author

I don't think we can. Python 2 is officially 100% dead and unsupported as of a year ago, and sticking with that means we can't use the new features available in more recent versions. I see literally no downside to dropping Python 2 support so that we can make Python 3 support better.

@lkraider
Copy link
Contributor

LGTM. Great work @kstrauser !

Moving to Python 3 is important to keep maintenance manageable, contributions are scarce as it is.

@Mizaro is there some existing PR you would request for a last Python2 release?

@kstrauser
Copy link
Contributor Author

@lkraider Thanks, and I'm glad you liked it! It could have gone another way: "thanks for dropping this giant ball of mud PR on me, un-asked for." 馃榾

As a practical matter, since this is a very backward-incompatible change, I could see a release process like this:

  • Rename the current master branch to something like v2 or schematics2 or such. Then we could continue to easily merge PRs onto that if appropriate, say if someone fixed a Python 2-specific bug.
  • I opened this PR to merge into a new schematics3 branch, but maybe we rename that to main, dev, or similar so that if people were previously tracking master it would break their build instead of merging in a new likely incompatible version.

Then the main branch of Schematics would be on the new Python 3 version, but the old version would still exist for people who need it.

What do you think? Please take the above in the spirit of "Kirk brainstorming ways to make this as easy as possible for everyone", not "Kirk trying to dictate how to run a project he's only active with every few years". 馃檪

@hugovk
Copy link

hugovk commented Aug 4, 2021

As a practical matter, ...

I'd recommend keeping branches as is, and using tags for versions. That would be much cleaner.

  • Then we could continue to easily merge PRs onto that if appropriate, say if someone fixed a Python 2-specific bug.

Are you considering still maintaining for Python 2? I'd suggest drawing a line and not bothering at this point, it's been dead 19 months and many projects have dropped it. And this PR is titled "All in on Python 3" :)

Then the main branch of Schematics would be on the new Python 3 version, but the old version would still exist for people who need it.

The old version will still exist anyway on PyPI and in the repo via tags. Make sure to add python_requires=">=3.6", to setup.py, that way pip will know to install the new version for 3.6+ and will use the previous version for anyone still on 2.7 etc.

@kstrauser
Copy link
Contributor Author

@hugovk You've convinced me.

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.

None yet

5 participants