Skip to content
Open
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 @@ -188,15 +188,17 @@ def get(self, *args: Any, **kwargs: Any) -> Arrow:

arg_count = len(args)
locale = kwargs.pop("locale", DEFAULT_LOCALE)
tzinfo_provided = "tzinfo" in kwargs
tz = kwargs.get("tzinfo", None)
normalize_whitespace = kwargs.pop("normalize_whitespace", False)

# if kwargs given, send to constructor unless only tzinfo provided
if len(kwargs) > 1:
arg_count = 3

# tzinfo kwarg is not provided
if len(kwargs) == 1 and tz is None:
# Treat an explicit tzinfo=None the same as omitting tzinfo, but keep
# other single-keyword cases (for example year=...) on the constructor path.
if len(kwargs) == 1 and tz is None and not tzinfo_provided:
arg_count = 3

# () -> now, @ tzinfo or utc
Expand Down
5 changes: 5 additions & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ def test_kwarg_tzinfo_string(self):
with pytest.raises(ParserError):
self.factory.get(tzinfo="US/PacificInvalidTzinfo")

def test_kwarg_tzinfo_none(self):
result = self.factory.get("2013-01-01", "YYYY-MM-DD", tzinfo=None)

assert result._datetime == datetime(2013, 1, 1, tzinfo=tz.tzutc())

def test_kwarg_normalize_whitespace(self):
result = self.factory.get(
"Jun 1 2005 1:33PM",
Expand Down
Loading