Fix target argument of pathlib.Path.{sym,hard}link_to#10019
Fix target argument of pathlib.Path.{sym,hard}link_to#10019srittau merged 1 commit intopython:mainfrom
Conversation
254c007 to
ebc0ebd
Compare
This comment has been minimized.
This comment has been minimized.
srittau
left a comment
There was a problem hiding this comment.
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
|
The underlying
os.{sym,}linkfunctions 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