chadrik commented on a change in pull request #11022: [BEAM-7746] Resolve 
typing issues in filesystem
URL: https://github.com/apache/beam/pull/11022#discussion_r386809980
 
 

 ##########
 File path: sdks/python/apache_beam/io/localfilesystem.py
 ##########
 @@ -136,10 +137,17 @@ def _path_open(
       mode,
       mime_type='application/octet-stream',
       compression_type=CompressionTypes.AUTO):
+    # type: (...) -> BinaryIO
+
     """Helper functions to open a file in the provided mode.
     """
     compression_type = FileSystem._get_compression_type(path, compression_type)
-    raw_file = open(path, mode)
+    if mode == 'r':
+      mode = 'rb'
+    elif mode == 'w':
+      mode = 'wb'
 
 Review comment:
   I saw this pattern in other filesystems so I thought I'd add it here to make 
it completely obvious that the subsequent cast to `BinaryIO` (from `IO[Any]`) 
is safe and warranted. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to