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

fixing narrow type-hint #266

Closed
wants to merge 3 commits into from

Conversation

keller00
Copy link
Contributor

fixes #258

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

test please

@@ -95,11 +95,13 @@ def __init__(
If this is set to ``False`` then the lock will be reentrant across threads.
"""
self._is_thread_local = thread_local
path = os.fspath(lock_file)
path_str = path.decode() if isinstance(path, bytes) else path
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, with this I'm no longer sure this is something we want to support. The user can put their casting at call side if they must, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other parts of the code depend in this being a str, like these debug logging lines (otherwise we get b'log lines').

So the choice for me was whether to do filename.decode() if isinstance(filename, bytes) else filename in multiple spots, or make sure that it's str at init time.

@keller00
Copy link
Contributor Author

@gaborbernat I don't mind if you decide to not accept the PR. I was trying to help close the low hanging issues. 😄
The one thing that I'd like to change is this type-hint here.
I believe lock_file: str | os.PathLike[Any], should instead be lock_file: str | os.PathLike[AnyStr],, but I'm happy to open a differentPR for that

@gaborbernat
Copy link
Member

@gaborbernat I don't mind if you decide to not accept the PR. I was trying to help close the low hanging issues. 😄
The one thing that I'd like to change is this type-hint here.
I believe lock_file: str | os.PathLike[Any], should instead be lock_file: str | os.PathLike[AnyStr],, but I'm happy to open a differentPR for that

Let's do that 👍

@keller00 keller00 deleted the keller00/narrow_typing branch August 26, 2023 02:19
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.

The type annotation for the lock_file __init__ parameter is too narrow
2 participants