-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
function
argument in shutil.register_unpack_format
must be Callable
#7083
Conversation
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This comment has been minimized.
This comment has been minimized.
name: str, extensions: list[str], function: Any, extra_args: Sequence[tuple[str, Any]] | None = ..., description: str = ... | ||
name: str, | ||
extensions: list[str], | ||
function: Callable[..., object], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be approximately Callable[[str, str], object]
, where the first arg is the filename and the second is the target directory. But it also passes whatever is in extra_args
as **kwargs to the unpack function. I don't think we can express that accurately, so let's stick with ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about using an @overload
for case when extra_args
are None
, but this might be an over-kill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that works if you're interested in making this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I have to now 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to, I'm happy to merge this change as is if you prefer.
But better types are, well, better :)
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Docs: https://docs.python.org/3/library/shutil.html#shutil.register_unpack_format