jorisvandenbossche commented on a change in pull request #8067: URL: https://github.com/apache/arrow/pull/8067#discussion_r478501543
########## File path: python/pyarrow/_fs.pyx ########## @@ -419,17 +420,27 @@ cdef class FileSystem(_Weakrefable): vector[c_string] paths CFileSelector selector + single_path = False if isinstance(paths_or_selector, FileSelector): with nogil: selector = (<FileSelector>paths_or_selector).selector infos = GetResultValue(self.fs.GetFileInfo(selector)) - elif isinstance(paths_or_selector, (list, tuple)): - paths = [_path_as_bytes(s) for s in paths_or_selector] + else: + if isinstance(paths_or_selector, (list, tuple)): + paths = [_path_as_bytes(s) for s in paths_or_selector] + else: + try: + paths = [_path_as_bytes(paths_or_selector)] + except TypeError: + raise TypeError( + "Must pass either path(s) or a FileSelector" + ) + single_path = True with nogil: infos = GetResultValue(self.fs.GetFileInfo(paths)) Review comment: I only noticed afterwards that `GetFileInfo` can also accept a single string instead of a vector (and which is exposed in libarrow_fs.pxd). That might be a bit cleaner than the above ---------------------------------------------------------------- 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