Skip to content

[python-dateutil] dateutil.parser.parse(fuzzy_with_tokens=True) returns a tuple#15474

Open
ellieayla wants to merge 3 commits intopython:mainfrom
ellieayla:dateutil-fuzzy_with_tokens
Open

[python-dateutil] dateutil.parser.parse(fuzzy_with_tokens=True) returns a tuple#15474
ellieayla wants to merge 3 commits intopython:mainfrom
ellieayla:dateutil-fuzzy_with_tokens

Conversation

@ellieayla
Copy link
Contributor

@overload the parse function at module and class level, separate return type for fuzzy_with_tokens: Literal[True] and Literal[False].

Note, not entirely sure this syntax is perfect. mypy is happy locally, but that doesn't check against the upstream library behaviour. Could use a second pair of eyes.

Closes issue #15473

ref:

https://github.com/dateutil/dateutil/blob/e081f6725fbb49cae6eedab7010f517e8490859b/src/dateutil/parser/_parser.py#L702

https://github.com/dateutil/dateutil/blob/e081f6725fbb49cae6eedab7010f517e8490859b/src/dateutil/parser/_parser.py#L871

…ns a tuple

@overload the parse function at module and class level, separate return type for fuzzy_with_tokens: Literal[True] and Literal[False].

Note, not entirely sure this syntax is perfect. mypy is happy locally, but that doesn't check against the upstream library behaviour. Could use a second pair of eyes.

Closes issue python#15473

ref:

https://github.com/dateutil/dateutil/blob/e081f6725fbb49cae6eedab7010f517e8490859b/src/dateutil/parser/_parser.py#L702

https://github.com/dateutil/dateutil/blob/e081f6725fbb49cae6eedab7010f517e8490859b/src/dateutil/parser/_parser.py#L871
@github-actions

This comment has been minimized.

@ellieayla
Copy link
Contributor Author

uv run mypy stubs/python-dateutil/dateutil
Success: no issues found in 17 source files

uv run mypy --strict stubs/python-dateutil/dateutil
stubs/python-dateutil/dateutil/tz/_common.pyi:15: error: Function is missing a return type annotation  [no-untyped-def]
stubs/python-dateutil/dateutil/parser/_parser.pyi:156: error: Function is missing a return type annotation  [no-untyped-def]  # __init__
stubs/python-dateutil/dateutil/parser/_parser.pyi:156: note: Use "-> None" if function does not return a value
stubs/python-dateutil/dateutil/rrule.pyi:65: error: Function is missing a return type annotation  [no-untyped-def]
stubs/python-dateutil/dateutil/rrule.pyi:66: error: Function is missing a return type annotation  [no-untyped-def]

The untyped definiton in stubs/python-dateutil/dateutil/parser/_parser.pyi:156 is just an __init__ that could be typed None. The other 3 function definitions missing return types are more complex, and I haven't tried to type them.

cc @lev-blit @donbarbos

Copy link
Contributor

@donbarbos donbarbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Only one comment

ellieayla and others added 2 commits February 28, 2026 16:55
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@ellieayla ellieayla requested a review from donbarbos February 28, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants