You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/04 18:14:47 UTC

[GitHub] [beam] damccorm opened a new issue, #20580: pathlib.Path, PathLike and __fspath__ support (PEP 519)

damccorm opened a new issue, #20580:
URL: https://github.com/apache/beam/issues/20580

   It would be nice to support `pathlib.Path`-like objects, as per PEP 519: https://www.python.org/dev/peps/pep-0519/
   
   Currently, the following fail with: `TypeError: file_path_prefix must be a string or ValueProvider;got PosixPath('/tmp/pytest-of-forge-00/pytest-0/test_ptransform_beam0/output0.txt') instead`
   
   ```
   
   import pathlib
   
   path = pathlib.Path('/path/to/home')
   beam.io.WriteToText(path)
   
   ```
   
   
   Raised by FileBasedSink:
   
   ```
   
   class FileBasedSink(iobase.Sink):
   
     def __init__(self)
       if not isinstance(file_path_prefix,
   ((str, unicode), ValueProvider)):
         raise TypeError(...)
   
   ```
   
   
   It could be implemented by calling `os.fspath(file_path_prefix)`
   
   Imported from Jira [BEAM-11135](https://issues.apache.org/jira/browse/BEAM-11135). Original Jira may contain additional context.
   Reported by: conchylicultor.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org