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

v0.15.0: More robust parsing and support for ordinal dates and 8601 basic format #655

Merged
merged 60 commits into from Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
47445f9
started some fixes for get method
jadchaar Jun 23, 2019
df49462
Current progress of fixing get
jadchaar Jun 23, 2019
4fea9ea
Merge master
jadchaar Jun 23, 2019
d69d16c
Create custom warning class for get changes
systemcatch Jun 24, 2019
a50137f
More progress toward GET fixes
jadchaar Jun 29, 2019
8d17963
Merge in latest changes and further improvements to get
jadchaar Jun 29, 2019
12c1b4c
Reverted change to handling of Z string
jadchaar Jun 29, 2019
b67c9e2
Added a number of new formatting changes
jadchaar Jun 29, 2019
824b744
Removed unnecessary helper functions in parser class and cleaned up s…
jadchaar Jun 30, 2019
dc2e6d2
Fixed bug with YY mapping to 20
jadchaar Jun 30, 2019
955850c
Add tests for .get() warnings and comment on current problems
systemcatch Jul 6, 2019
91d99d7
Added comments and tests
jadchaar Jul 6, 2019
cd9297f
Added comments and tests
jadchaar Jul 6, 2019
6ab1c0b
Fixed merging issues
jadchaar Jul 7, 2019
e3126c7
Fixed a number of parsing issues with a couple of regex tweaks and ad…
jadchaar Jul 8, 2019
f77e698
Added unit tests and added cleanup/validation to datetimte string in …
jadchaar Jul 8, 2019
0b26c12
Merge pull request #609 from jadchaar/regex-get-fixes
jadchaar Jul 9, 2019
4c331c7
Tweaked space and t divider checks and added a few more test inputs
jadchaar Jul 9, 2019
08df568
Split up recently added parse_iso and parse unit tests and removed fr…
jadchaar Jul 9, 2019
f1f2581
Merged master
jadchaar Jul 13, 2019
7622b8b
Fixed bugs with basic format and multiple subsecond tokens
jadchaar Jul 13, 2019
824a655
Added an extra french test
jadchaar Jul 13, 2019
188693d
Fixed an issue with the timestamp not strictly matching
jadchaar Jul 13, 2019
e480ea0
Added overflow error test to is_timestamp
jadchaar Jul 13, 2019
3f1a3c9
Attempt at fixing linting
jadchaar Jul 13, 2019
87f63fb
Added support for DDD and DDDD tokens in arrow.get()
jadchaar Jul 14, 2019
a6995ba
Cleaned up timestamp docs
jadchaar Jul 14, 2019
d4bcb73
Added tests for new timestring changes
jadchaar Jul 28, 2019
6c8fbba
Add tests for DDD and DDDD tokens
systemcatch Jul 30, 2019
3fb6a33
Merge master
jadchaar Aug 1, 2019
be87f39
Further test cases for DDD and DDDD tokens
systemcatch Aug 1, 2019
f02c8d7
Add test cases for iso8601 basic format
systemcatch Aug 2, 2019
d152923
Added back support for multiple subsecond tokens to align with format…
jadchaar Aug 4, 2019
1b8e36b
Revamped regex of tz--work in progress
jadchaar Aug 4, 2019
4db7145
Replace hard coded timestamp with time.time()
jadchaar Aug 5, 2019
4c360cb
Tweaked tzinfo parser regex and added some TODOs
jadchaar Aug 9, 2019
409b855
Added a comment to tzinfoparser
jadchaar Aug 10, 2019
4ed43ae
Finalized regex changes
jadchaar Aug 13, 2019
87684c1
Added remaining regex tests
jadchaar Aug 13, 2019
62e8ced
Added a few comments
jadchaar Aug 13, 2019
46f30b2
Make error messages clearer and add extra DDDD test
systemcatch Aug 16, 2019
4e36c9a
Fixed a critical bug with X token and float timestamps; revamped basi…
jadchaar Aug 16, 2019
6f13d10
Added tests and removed stripping of whitespace
jadchaar Aug 16, 2019
ed75554
Merge branch 'master' into Version-0.15.0
jadchaar Aug 16, 2019
211206e
Merge version 0.15.0 branch
jadchaar Aug 16, 2019
d9cb79e
Increment version
jadchaar Aug 16, 2019
d7e083b
Fixed float timestamp on py27, removed warnings, changed parser error…
jadchaar Aug 17, 2019
992038d
Added tests and cleaned up TODOs
jadchaar Aug 17, 2019
fca6522
Added ordinal tests and added new error type to fix exception bubblin…
jadchaar Aug 17, 2019
d63fd39
Consolidate and clean up errors for spacing
jadchaar Aug 17, 2019
e998373
Consolidate and clean up errors for spacing
jadchaar Aug 17, 2019
9940542
Cleaned up a comment
jadchaar Aug 17, 2019
66d09f8
Reverted version increment; added tests to get coverage to 100%
jadchaar Aug 19, 2019
32fe0a5
Removed mixing of formatS
jadchaar Aug 19, 2019
66e97fe
Changed checking of basic time format
jadchaar Sep 8, 2019
4a1c4c1
Merge pull request #639 from jadchaar/tz-changes
jadchaar Sep 8, 2019
b9668a4
Merged master and resolve conflicts
jadchaar Sep 8, 2019
9aa2cb5
Upgraded pre-commit packages
jadchaar Sep 8, 2019
ca1bb57
Added tests for leading and trailing whitespace
jadchaar Sep 8, 2019
3160c4c
Added test for comma subsecond separator and moved setting of tz_form…
jadchaar Sep 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -24,7 +24,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v1.22.1
rev: v1.23.0
hooks:
- id: pyupgrade
- repo: https://github.com/pre-commit/pygrep-hooks
Expand All @@ -33,7 +33,7 @@ repos:
- id: python-no-eval
- id: python-check-blanket-noqa
- id: rst-backticks
- repo: https://github.com/python/black
- repo: https://github.com/psf/black
rev: 19.3b0
hooks:
- id: black
Expand Down
2 changes: 1 addition & 1 deletion arrow/arrow.py
Expand Up @@ -1372,7 +1372,7 @@ def _get_iteration_params(cls, end, limit):
if end is None:

if limit is None:
raise Exception("one of 'end' or 'limit' is required")
raise ValueError("one of 'end' or 'limit' is required")

return cls.max, limit

Expand Down
38 changes: 7 additions & 31 deletions arrow/factory.py
Expand Up @@ -9,7 +9,6 @@
from __future__ import absolute_import

import calendar
import warnings
from datetime import date, datetime
from datetime import tzinfo as dt_tzinfo
from time import struct_time
Expand All @@ -21,18 +20,6 @@
from arrow.util import is_timestamp, isstr


class ArrowParseWarning(DeprecationWarning):
"""Raised when arrow.get() is passed a string with no formats and matches incorrectly
on one of the default formats.

e.g.
arrow.get('blabla2016') -> <Arrow [2016-01-01T00:00:00+00:00]>
arrow.get('13/4/2045') -> <Arrow [2045-01-01T00:00:00+00:00]>

In version 0.15.0 this warning will become a ParserError.
"""


class ArrowFactory(object):
""" A factory for generating :class:`Arrow <arrow.arrow.Arrow>` objects.

Expand Down Expand Up @@ -73,7 +60,7 @@ def get(self, *args, **kwargs):
>>> arrow.get(arw)
<Arrow [2013-10-23T15:21:54.354846+00:00]>

**One** ``str``, ``float``, or ``int``, convertible to a floating-point timestamp, to get
**One** ``float`` or ``int``, convertible to a floating-point timestamp, to get
that timestamp in UTC::

>>> arrow.get(1367992474.293378)
Expand All @@ -82,17 +69,16 @@ def get(self, *args, **kwargs):
>>> arrow.get(1367992474)
<Arrow [2013-05-08T05:54:34+00:00]>

>>> arrow.get('1367992474.293378')
<Arrow [2013-05-08T05:54:34.293378+00:00]>

>>> arrow.get('1367992474')
<Arrow [2013-05-08T05:54:34+00:00]>

**One** ISO-8601-formatted ``str``, to parse it::

>>> arrow.get('2013-09-29T01:26:43.830580')
<Arrow [2013-09-29T01:26:43.830580+00:00]>

**One** ISO-8601-formatted ``str``, in basic format, to parse it::

>>> arrow.get('20160413T133656.456289')
<Arrow [2016-04-13T13:36:56.456289+00:00]>

**One** ``tzinfo``, to get the current time **converted** to that timezone::

>>> arrow.get(tz.tzlocal())
Expand Down Expand Up @@ -177,7 +163,7 @@ def get(self, *args, **kwargs):
if arg is None:
return self.type.utcnow()

# try (int, float, str(int), str(float)) -> utc, from timestamp.
# try (int, float) -> utc, from timestamp.
if is_timestamp(arg):
return self.type.utcfromtimestamp(arg)

Expand All @@ -199,11 +185,6 @@ def get(self, *args, **kwargs):

# (str) -> parse.
elif isstr(arg):
warnings.warn(
"The .get() parsing method without a format string will parse more strictly in version 0.15.0."
"See https://github.com/crsmithdev/arrow/issues/612 for more details.",
ArrowParseWarning,
)
dt = parser.DateTimeParser(locale).parse_iso(arg)
return self.type.fromdatetime(dt, tz)

Expand Down Expand Up @@ -246,11 +227,6 @@ def get(self, *args, **kwargs):

# (str, format) -> parse.
elif isstr(arg_1) and (isstr(arg_2) or isinstance(arg_2, list)):
warnings.warn(
"The .get() parsing method with a format string will parse more strictly in version 0.15.0."
"See https://github.com/crsmithdev/arrow/issues/612 for more details.",
ArrowParseWarning,
)
dt = parser.DateTimeParser(locale).parse(args[0], args[1])
return self.type.fromdatetime(dt, tzinfo=tz)

Expand Down