Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions arrow/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ def get(self, *args: Any, **kwargs: Any) -> Arrow:
if len(kwargs) > 1:
arg_count = 3

# tzinfo kwarg is not provided
if len(kwargs) == 1 and tz is None:
# the single remaining kwarg is for the constructor, not tzinfo
# (checking "tzinfo" not in kwargs so an explicit tzinfo=None is
# treated like an omitted tzinfo instead of a constructor argument)
if len(kwargs) == 1 and "tzinfo" not in kwargs:
arg_count = 3

# () -> now, @ tzinfo or utc
Expand Down
9 changes: 9 additions & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ def test_two_args_other(self):
with pytest.raises(TypeError):
self.factory.get(object(), object())

# regression test for issue #1259
def test_explicit_tzinfo_none(self):
# passing tzinfo=None should behave the same as omitting it, rather
# than routing the call to the Arrow constructor
expected = datetime(2013, 1, 1, tzinfo=tz.tzutc())

assert self.factory.get("2013-01-01", "YYYY-MM-DD", tzinfo=None) == expected
assert self.factory.get("2013-01-01", tzinfo=None) == expected

def test_three_args_with_tzinfo(self):
timefmt = "YYYYMMDD"
d = "20150514"
Expand Down
Loading