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

Invalid path causes TypeError due to shadowed builtin type #761

Closed
aazuspan opened this issue Jan 3, 2024 · 2 comments · Fixed by #762
Closed

Invalid path causes TypeError due to shadowed builtin type #761

aazuspan opened this issue Jan 3, 2024 · 2 comments · Fixed by #762
Labels
bug Did we break something? p2-medium

Comments

@aazuspan
Copy link
Contributor

aazuspan commented Jan 3, 2024

When you pass an invalid path type to Live.log_artifact, it's supposed to raise an InvalidDataTypeError:

dvclive/src/dvclive/live.py

Lines 493 to 494 in 47c87b3

if not isinstance(path, (str, Path)):
raise InvalidDataTypeError(path, type(path))

Instead, it raises TypeError: str is not callable because the builtin type is shadowed by the parameter:

type: Optional[str] = None, # noqa: A002

It's a pretty minor issue, but I thought I'd point it out since it could cause some confusion. Thanks!

@dberenbaum
Copy link
Contributor

@aazuspan Do you have an interest in contributing a fix? We are probably stuck with the type arg name at least until the next major version release, but we could probably work around the issue another way (like move the type checking outside of log_artifact() or checking the type with path.__class__).

@dberenbaum dberenbaum added bug Did we break something? p2-medium labels Jan 4, 2024
@aazuspan
Copy link
Contributor Author

aazuspan commented Jan 4, 2024

Sure, I'll make a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Did we break something? p2-medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants