Skip to content

Commit 41681d2

Browse files
Fix line length and whitespace issues in dateutil files
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
1 parent 0f38e1c commit 41681d2

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

kubernetes/base/config/dateutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def parse_rfc3339(s):
7676
if tz_match is None:
7777
raise ValueError(
7878
f"Invalid timezone format in RFC3339 string {s!r}: "
79-
f"timezone part {groups[7]!r} does not match expected format (±HH:MM)"
79+
f"timezone part {groups[7]!r} does not match expected "
80+
f"format (±HH:MM)"
8081
)
8182
tz_groups = tz_match.groups()
8283
hour = int(tz_groups[1])

kubernetes/base/config/dateutil_test.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,22 @@ def test_parse_rfc3339_error_message_clarity(self):
104104
self.assertIn("expected", error_msg)
105105

106106
def test_parse_rfc3339_handles_none_from_timezone_regex(self):
107-
"""Test that parse_rfc3339 handles cases where timezone regex returns None.
108-
109-
This test addresses the GitHub issue where parse_rfc3339 was calling .groups()
110-
on None when the timezone regex failed to match, causing:
111-
'NoneType' object has no attribute 'groups'
112-
113-
The fix adds a check to ensure _re_timezone.search() result is not None
114-
before calling .groups(), and provides a clear error message.
107+
"""Test parse_rfc3339 handles timezone regex returning None.
108+
109+
This test addresses the GitHub issue where parse_rfc3339 was
110+
calling .groups() on None when the timezone regex failed to match,
111+
causing: 'NoneType' object has no attribute 'groups'
112+
113+
The fix adds a check to ensure _re_timezone.search() result is
114+
not None before calling .groups(), and provides a clear error
115+
message.
115116
"""
116-
# The main RFC3339 regex allows space in the timezone position: [zZ ]
117+
# The main RFC3339 regex allows space in timezone position: [zZ ]
117118
# If a space ends up in groups[7], it should be handled gracefully
118119
# Since the current code uses strip(), trailing spaces are removed,
119120
# but the fix ensures robustness for any edge case
120-
121+
121122
# Test that space in timezone is treated as UTC (like Z/z)
122-
actual = parse_rfc3339("2017-07-25 04:44:21") # No timezone specified
123+
actual = parse_rfc3339("2017-07-25 04:44:21")
123124
expected = datetime(2017, 7, 25, 4, 44, 21, 0, UTC)
124125
self.assertEqual(expected, actual)

0 commit comments

Comments
 (0)