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

Deprecate Python 2.7 and Python 3.5 #877

Merged
merged 7 commits into from
Nov 10, 2020
Merged

Deprecate Python 2.7 and Python 3.5 #877

merged 7 commits into from
Nov 10, 2020

Conversation

jadchaar
Copy link
Member

@jadchaar jadchaar commented Nov 8, 2020

Python 2.7 & 3.5 Deprecation Checklist

  • Update setup.py classifiers and python_requires to declare arrow only supports Python 3.6+
  • Drop Python < 3.6 from CI
  • Remove Python < 3.6 from Makefile
  • Run pyupgrade --py36-plus
  • Convert all formatting to f-strings (should be done by pyupgrade)
  • Remove all future imports
  • Remove any remaining python 2 import shadowing
  • Audit and overhaul requirements file
  • Change timestamp formatting to use datetime.timestamp()
  • Update timestamp calls in formatter.py
  • Replace hardcoded MAX_TIMESTAMP constant with datetime.max.timestamp()
  • Convert isinstance(value, numbers.Integral) to isinstance(value, int)
  • Remove isstr function
  • Remove __cmp__() method in arrow.py
  • Remove coverage pragmas and skipped tests for py27
  • Revisit enfold calls in code @systemcatch

Breaking changes for v1.0.0

  • Change timestamp from property to method in arrow.py (requires deprecation warning beforehand)
  • Change the return value of Arrow's timestamp method (currently a property) to a float

General Changes for v1.0.0

  • Remove beta label from setup.py

Closes: #465
Closes: #861
Closes: #739

@codecov
Copy link

codecov bot commented Nov 8, 2020

Codecov Report

Merging #877 (6fc80d9) into master (609b630) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #877   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines         1810      1796   -14     
  Branches       312       313    +1     
=========================================
- Hits          1810      1796   -14     
Impacted Files Coverage Δ
arrow/api.py 100.00% <ø> (ø)
arrow/arrow.py 100.00% <100.00%> (ø)
arrow/constants.py 100.00% <100.00%> (ø)
arrow/factory.py 100.00% <100.00%> (ø)
arrow/formatter.py 100.00% <100.00%> (ø)
arrow/locales.py 100.00% <100.00%> (ø)
arrow/parser.py 100.00% <100.00%> (ø)
arrow/util.py 100.00% <100.00%> (ø)

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 609b630...6fc80d9. Read the comment docs.

@jadchaar jadchaar requested review from krisfremen and systemcatch and removed request for krisfremen November 8, 2020 19:09
@jadchaar jadchaar changed the title Py27/35 deprecation Deprecate Python 2.7 and Python 3.5 Nov 8, 2020
@jadchaar
Copy link
Member Author

jadchaar commented Nov 8, 2020

Should be ready for review @systemcatch @krisfremen. All what remains is updating the enfold calls, which @systemcatch is more familiar with.

Copy link
Collaborator

@systemcatch systemcatch left a comment

Choose a reason for hiding this comment

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

Hey @jadchaar just a few comments but otherwise it looks very solid.

The enfold calls aren't an issue on python 3.6+, I suggest we leave them for a later PR as the users won't see much difference.

.pre-commit-config.yaml Show resolved Hide resolved
Comment on lines -723 to +700
return calendar.timegm(self._datetime.utctimetuple())
return int(self.timestamp())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably best to stick with old way to guarantee compatibility.

arrow/arrow.py Show resolved Hide resolved
arrow/parser.py Show resolved Hide resolved
setup.cfg Show resolved Hide resolved
@jadchaar
Copy link
Member Author

jadchaar commented Nov 9, 2020

Thanks for the feedback. We had a note to revisit enfold in the copy constructor since we would now be able to just copy the datetime object as is rather than having to enfold again. Do we want to ignore that and just leave it for a future PR?

@systemcatch
Copy link
Collaborator

Thanks for the feedback. We had a note to revisit enfold in the copy constructor since we would now be able to just copy the datetime object as is rather than having to enfold again. Do we want to ignore that and just leave it for a future PR?

Not sure what you mean by copy constructor?

@jadchaar
Copy link
Member Author

jadchaar commented Nov 9, 2020

Oh oops sorry I meant replace:

arrow/arrow/arrow.py

Lines 777 to 823 in 609b630

def replace(self, **kwargs):
"""Returns a new :class:`Arrow <arrow.arrow.Arrow>` object with attributes updated
according to inputs.
Use property names to set their value absolutely::
>>> import arrow
>>> arw = arrow.utcnow()
>>> arw
<Arrow [2013-05-11T22:27:34.787885+00:00]>
>>> arw.replace(year=2014, month=6)
<Arrow [2014-06-11T22:27:34.787885+00:00]>
You can also replace the timezone without conversion, using a
:ref:`timezone expression <tz-expr>`::
>>> arw.replace(tzinfo=tz.tzlocal())
<Arrow [2013-05-11T22:27:34.787885-07:00]>
"""
absolute_kwargs = {}
for key, value in kwargs.items():
if key in self._ATTRS:
absolute_kwargs[key] = value
elif key in ["week", "quarter"]:
raise AttributeError("setting absolute {} is not supported".format(key))
elif key not in ["tzinfo", "fold"]:
raise AttributeError('unknown attribute: "{}"'.format(key))
current = self._datetime.replace(**absolute_kwargs)
tzinfo = kwargs.get("tzinfo")
if tzinfo is not None:
tzinfo = self._get_tzinfo(tzinfo)
current = current.replace(tzinfo=tzinfo)
fold = kwargs.get("fold")
# TODO revisit this once we drop support for 2.7/3.5
if fold is not None:
current = dateutil_tz.enfold(current, fold=fold)
return self.fromdatetime(current)

We probably don't need enfold here anymore since datetime would replace fold natively. Thoughts?

@systemcatch
Copy link
Collaborator

systemcatch commented Nov 10, 2020

You're right, how about I make an issue to update the enfold calls after 1.0.0 is released?

@jadchaar
Copy link
Member Author

Ref: #878

Want to approve so we can get this merged @systemcatch?

@jadchaar jadchaar merged commit 30d16c1 into master Nov 10, 2020
@jadchaar jadchaar deleted the py27-35-deprecation branch November 10, 2020 21:02
@jadchaar
Copy link
Member Author

@isac322 You should be good to now implement type checking off of master!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants