You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The --expiration option in kaggle auth print-access-token was not parsing duration values correctly. Inputs like 6h, 2d, and 30s caused an uncaught TypeError because the duration suffix was passed directly to relativedelta() as a single-letter keyword. The CLI also advertised formats like 2:30 and 2h30s, even though they were not actually supported.
Fix
Mapped short duration suffixes (s, m, h, d, w) to the correct relativedelta keyword arguments.
Improved validation so invalid inputs now return a friendly ValueError instead of a Python traceback.
Updated the CLI help text, method docstring, and documentation to reflect the formats that are actually supported.
@sridipbasu It looks like we still need the comment to disable type checking for the call to relativedelta() on line 1674: # type: ignore[arg-type]. I think that is why the lint check fails. (Excuse me for jumping in before you're ready for a review)
You're right. While refactoring _parse_duration(), I kept the relativedelta(**{unit: value}) call but accidentally removed the original # type: ignore[arg-type] comment.
Since mypy uses the types-python-dateutil stubs, it can't infer the dynamically constructed keyword arguments passed to relativedelta(), so it reports the arg-type error that showed up in the lint job.
I've added the suppression back on the relativedelta() call. I also reproduced the lint failure locally with the dateutil stubs installed, confirmed that it disappears after restoring the comment, and verified that black and the relevant unit tests still pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
--expirationoption inkaggle auth print-access-tokenwas not parsing duration values correctly. Inputs like6h,2d, and30scaused an uncaughtTypeErrorbecause the duration suffix was passed directly torelativedelta()as a single-letter keyword. The CLI also advertised formats like2:30and2h30s, even though they were not actually supported.Fix
s,m,h,d,w) to the correctrelativedeltakeyword arguments.ValueErrorinstead of a Python traceback.Tests
Added regression tests to verify that:
30s,5m,6h,2d, and2wparse correctly.2:30,2h30s,6x,0h, etc.) raise a friendlyValueError.TypeError.Ran: