-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix target argument of pathlib.Path.{sym,hard}link_to #10019
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
Conversation
254c007
to
ebc0ebd
Compare
This comment has been minimized.
This comment has been minimized.
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.
Thanks! Just like in os
, we should just use _typeshed.StrOrBytesPath
here.
I haven't looked too closely at this PR, but (unlike |
The arguments to these functions skip any pathlib handling and just call the underlying functions, so bytes are accepted. |
My worry is that even if bytes paths technically work for this method, you probably shouldn't be using bytes paths with anything pathlib-y, it's bound to bite you at some point. But no strong opinion; happy for us to go with |
8d54f57
to
39464d1
Compare
The underlying os.{sym,}link functions take any StrOrBytesPath.
39464d1
to
508f479
Compare
I have made the requested change to |
Diff from mypy_primer, showing the effect of this PR on open source code: bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch_storage_plugins/swift.py: note: In member "symlink_to" of class "SwiftPath":
+ src/bandersnatch_storage_plugins/swift.py:415: error: Signature of "symlink_to" incompatible with supertype "Path" [override]
+ src/bandersnatch_storage_plugins/swift.py:415: note: Superclass:
+ src/bandersnatch_storage_plugins/swift.py:415: note: def symlink_to(self, target: Union[str, bytes, PathLike[str], PathLike[bytes]], target_is_directory: bool = ...) -> None
+ src/bandersnatch_storage_plugins/swift.py:415: note: Subclass:
+ src/bandersnatch_storage_plugins/swift.py:415: note: def symlink_to(self, src: Union[Path, str], target_is_directory: bool = ..., src_container: Optional[str] = ..., src_account: Optional[str] = ...) -> None
|
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.
Thanks!
The underlying
os.{sym,}link
functions take any PathLike object:typeshed/stdlib/os/__init__.pyi
Lines 749 to 751 in 1c0500a
typeshed/stdlib/os/__init__.pyi
Lines 700 to 707 in 1c0500a