Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typecheck can be added to _pydatetime.timedelta.__new__ #126947

Closed
bombs-kim opened this issue Nov 18, 2024 · 0 comments
Closed

Typecheck can be added to _pydatetime.timedelta.__new__ #126947

bombs-kim opened this issue Nov 18, 2024 · 0 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@bombs-kim
Copy link
Contributor

bombs-kim commented Nov 18, 2024

Feature or enhancement

Proposal:

It seems that a typecheck can be added as suggested by the existing comment

    def __new__(cls, days=0, seconds=0, microseconds=0,
                milliseconds=0, minutes=0, hours=0, weeks=0):
        # Doing this efficiently and accurately in C is going to be difficult
        ...

        # XXX Check that all inputs are ints or floats.

Currently, an error is raised, but it's not explicit that it's because of an argument of wrong type

_pydatetime.timedelta(seconds='1')
# TypeError: can only concatenate str (not "int") to str

If this type check is not desirable, I think we can simply remove the comment.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
Archived in project
Development

No branches or pull requests

3 participants