Skip to content

add bytes and os.PathLike to ImageFolder type hint#4122

Open
wztdream wants to merge 1 commit intopytorch:mainfrom
wztdream:type_hint_for_ImageFolder
Open

add bytes and os.PathLike to ImageFolder type hint#4122
wztdream wants to merge 1 commit intopytorch:mainfrom
wztdream:type_hint_for_ImageFolder

Conversation

@wztdream
Copy link

Hi all,
This is to add bytes and os.PathLike type to ImageFolder type hint to avoid type checking warning see issue

@facebook-github-bot
Copy link
Contributor

Hi @wztdream!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

def __init__(
self,
root: str,
root: Union[str,bytes,os.PathLike],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @wztdream !

I'm confused, are we really allowing bytes type? @pmeier ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as we only use it within os.path functions, it should be fine. Question is if we want to do that. I'm not sure if it is worth it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I feel like this isn't something we'd want to explicitly support.
Or at the very least, I'm worried that we'll have to update the type annotation every single time os.path decides to support yet another thing

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Copy link
Contributor

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wztdream Thanks for the PR! Unfortunately, you would need to fix the annotation in more places, since DataFolder internally uses functions that currently are only annotated to take str's. You can run mypy to detect all these cases.

@vivekkumar7089
Copy link
Contributor

@wztdream, If you are busy with some other works, then please let me know. I will be happy to make a PR for this issue :).

@wztdream
Copy link
Author

wztdream commented Jul 5, 2021

@wztdream, If you are busy with some other works, then please let me know. I will be happy to make a PR for this issue :).

Sorry for the delay, I am busy these days, it is great you can help to fix this issue, go ahead and thank you for help :)

@wztdream
Copy link
Author

wztdream commented Jul 6, 2021

@wztdream Thanks for the PR! Unfortunately, you would need to fix the annotation in more places, since DataFolder internally uses functions that currently are only annotated to take str's. You can run mypy to detect all these cases.

Sorry for delay, I just have some time to update this PR, but I found it seems modify the type hint not a good way to solve this issue, as vivekkumar7089 have mentioned, following is the errors after run mypy. The impact seems too large, I think we need better way to handle pathlike typehint.

torchvision/datasets/vision.py:73: error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior 
[str-bytes-safe]
                body.append("Root location: {}".format(self.root))
                            ^
torchvision/datasets/folder.py:44: error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior 
[str-bytes-safe]
            raise FileNotFoundError(f"Couldn't find any class folder in {directory}.")
                                    ^
torchvision/datasets/folder.py:47: error: Incompatible return value type (got "Tuple[List[Union[str, bytes]], Dict[Union[str, bytes], int]]", expected
"Tuple[List[str], Dict[str, int]]")  [return-value]
        return classes, class_to_idx
               ^
torchvision/datasets/folder.py:154: error: Argument 1 to "find_classes" of "DatasetFolder" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
            classes, class_to_idx = self.find_classes(self.root)
                                                      ^
torchvision/datasets/folder.py:155: error: Argument 1 to "make_dataset" of "DatasetFolder" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
            samples = self.make_dataset(self.root, class_to_idx, extensions, is_valid_file)
                                        ^
torchvision/datasets/flickr.py:78: error: Argument 1 to "Flickr8kParser" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
            parser = Flickr8kParser(self.root)
                                    ^
torchvision/datasets/flickr.py:154: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            filename = os.path.join(self.root, img_id)
                                    ^
torchvision/datasets/widerface.py:109: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            filepath = os.path.join(self.root, "wider_face_split", filename)
                                    ^
torchvision/datasets/widerface.py:119: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                        img_path = os.path.join(self.root, "WIDER_" + self.split, "images", line)
                                                ^
torchvision/datasets/widerface.py:152: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            filepath = os.path.join(self.root, "wider_face_split", "wider_face_test_filelist.txt")
                                    ^
torchvision/datasets/widerface.py:158: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                    img_path = os.path.join(self.root, "WIDER_test", "images", line)
                                            ^
torchvision/datasets/widerface.py:168: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                extracted_dir = os.path.join(self.root, file)
                                             ^
torchvision/datasets/widerface.py:180: error: Argument 2 to "download_file_from_google_drive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
                download_file_from_google_drive(file_id, self.root, filename, md5)
                                                         ^
torchvision/datasets/widerface.py:181: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                filepath = os.path.join(self.root, filename)
                                        ^
torchvision/datasets/widerface.py:186: error: Argument "download_root" to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected
"str"  [arg-type]
                                         download_root=self.root,
                                                       ^
torchvision/datasets/voc.py:103: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            voc_root = os.path.join(self.root, base_dir)
                                    ^
torchvision/datasets/voc.py:106: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
                download_and_extract_archive(self.url, self.root, filename=self.filename, md5=self.md5)
                                                       ^
torchvision/datasets/usps.py:52: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            full_path = os.path.join(self.root, filename)
                                     ^
torchvision/datasets/usps.py:55: error: Argument 2 to "download_url" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
                download_url(url, self.root, filename, md5=checksum)
                                  ^
torchvision/datasets/svhn.py:70: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            loaded_mat = sio.loadmat(os.path.join(self.root, self.filename))
                                                  ^
torchvision/datasets/svhn.py:113: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            fpath = os.path.join(root, self.filename)
                                 ^
torchvision/datasets/svhn.py:118: error: Argument 2 to "download_url" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
            download_url(self.url, self.root, self.filename, md5)
                                   ^
torchvision/datasets/stl10.py:93: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                self.root, self.base_folder, self.class_names_file)
                ^
torchvision/datasets/stl10.py:144: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                    self.root, self.base_folder, labels_file)
                    ^
torchvision/datasets/stl10.py:148: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            path_to_data = os.path.join(self.root, self.base_folder, data_file)
                                        ^
torchvision/datasets/stl10.py:161: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                fpath = os.path.join(root, self.base_folder, filename)
                                     ^
torchvision/datasets/stl10.py:170: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
            download_and_extract_archive(self.url, self.root, filename=self.filename, md5=self.tgz_md5)
                                                   ^
torchvision/datasets/stl10.py:181: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                self.root, self.base_folder, self.folds_list_file)
                ^
torchvision/datasets/semeion.py:46: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            fp = os.path.join(self.root, self.filename)
                              ^
torchvision/datasets/semeion.py:81: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            fpath = os.path.join(root, self.filename)
                                 ^
torchvision/datasets/semeion.py:92: error: Argument 2 to "download_url" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
            download_url(self.url, root, self.filename, self.md5_checksum)
                                   ^
torchvision/datasets/sbu.py:48: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            file1 = os.path.join(self.root, 'dataset', 'SBU_captioned_photo_dataset_urls.txt')
                                 ^
torchvision/datasets/sbu.py:49: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            file2 = os.path.join(self.root, 'dataset', 'SBU_captioned_photo_dataset_captions.txt')
                                 ^
torchvision/datasets/sbu.py:54: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                filename = os.path.join(self.root, 'dataset', photo)
                                        ^
torchvision/datasets/sbu.py:68: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            filename = os.path.join(self.root, 'dataset', self.photos[index])
                                    ^
torchvision/datasets/sbu.py:86: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            fpath = os.path.join(root, self.filename)
                                 ^
torchvision/datasets/sbu.py:99: error: Argument 2 to "download_url" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
            download_url(self.url, self.root, self.filename, self.md5_checksum)
                                   ^
torchvision/datasets/sbu.py:102: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            with tarfile.open(os.path.join(self.root, self.filename), 'r:gz') as tar:
                                           ^
torchvision/datasets/sbu.py:106: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            with open(os.path.join(self.root, 'dataset', 'SBU_captioned_photo_dataset_urls.txt')) as fh:
                                   ^
torchvision/datasets/sbu.py:110: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                        download_url(url, os.path.join(self.root, 'dataset'))
                                                       ^
torchvision/datasets/sbd.py:75: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            image_dir = os.path.join(sbd_root, 'img')
                                     ^
torchvision/datasets/sbd.py:76: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            mask_dir = os.path.join(sbd_root, 'cls')
                                    ^
torchvision/datasets/sbd.py:79: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
                download_and_extract_archive(self.url, self.root, filename=self.filename, md5=self.md5)
                                                       ^
torchvision/datasets/sbd.py:80: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                extracted_ds_root = os.path.join(self.root, "benchmark_RELEASE", "dataset")
                                                 ^
torchvision/datasets/sbd.py:83: error: Argument 2 to "move" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                    shutil.move(old_path, sbd_root)
                                          ^
torchvision/datasets/sbd.py:84: error: Argument 2 to "download_url" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
                download_url(self.voc_train_url, sbd_root, self.voc_split_filename,
                                                 ^
torchvision/datasets/sbd.py:91: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            split_f = os.path.join(sbd_root, image_set.rstrip('\n') + '.txt')
                                   ^
torchvision/datasets/places365.py:108: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            return path.join(self.root, dir)
                             ^
torchvision/datasets/places365.py:116: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            file = path.join(self.root, file)
                             ^
torchvision/datasets/places365.py:131: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            file = path.join(self.root, file)
                             ^
torchvision/datasets/places365.py:143: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
            download_and_extract_archive(urljoin(self._BASE_URL, file), self.root, md5=md5)
                                                                        ^
torchvision/datasets/places365.py:153: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
            download_and_extract_archive(urljoin(self._BASE_URL, file), self.root, md5=md5)
                                                                        ^
torchvision/datasets/phototour.py:83: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            self.data_dir = os.path.join(self.root, name)
                                         ^
torchvision/datasets/phototour.py:84: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            self.data_down = os.path.join(self.root, '{}.zip'.format(name))
                                          ^
torchvision/datasets/phototour.py:85: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            self.data_file = os.path.join(self.root, '{}.pt'.format(name))
                                          ^
torchvision/datasets/phototour.py:139: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                fpath = os.path.join(self.root, filename)
                                     ^
torchvision/datasets/phototour.py:141: error: Argument 2 to "download_url" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
                download_url(url, self.root, filename, md5)
                                  ^
torchvision/datasets/omniglot.py:50: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            self.target_folder = join(self.root, self._get_target_folder())
                                      ^
torchvision/datasets/omniglot.py:83: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            if not check_integrity(join(self.root, zip_filename + '.zip'), self.zips_md5[zip_filename]):
                                        ^
torchvision/datasets/omniglot.py:95: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
            download_and_extract_archive(url, self.root, filename=zip_filename, md5=self.zips_md5[filename])
                                              ^
torchvision/datasets/mnist.py:147: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            return os.path.join(self.root, self.__class__.__name__, 'raw')
                                ^
torchvision/datasets/mnist.py:151: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            return os.path.join(self.root, self.__class__.__name__, 'processed')
                                ^
torchvision/datasets/kitti.py:135: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            return os.path.join(self.root, self.__class__.__name__, "raw")
                                ^
torchvision/datasets/imagenet.py:69: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            if not check_integrity(os.path.join(self.root, META_FILE)):
                                                ^
torchvision/datasets/imagenet.py:70: error: Argument 1 to "parse_devkit_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
                parse_devkit_archive(self.root)
                                     ^
torchvision/datasets/imagenet.py:74: error: Argument 1 to "parse_train_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
                    parse_train_archive(self.root)
                                        ^
torchvision/datasets/imagenet.py:76: error: Argument 1 to "parse_val_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
                    parse_val_archive(self.root)
                                      ^
torchvision/datasets/imagenet.py:80: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            return os.path.join(self.root, self.split)
                                ^
torchvision/datasets/cityscapes.py:113: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            self.images_dir = os.path.join(self.root, 'leftImg8bit', split)
                                           ^
torchvision/datasets/cityscapes.py:114: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            self.targets_dir = os.path.join(self.root, self.mode, split)
                                            ^
torchvision/datasets/cityscapes.py:139: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                    image_dir_zip = os.path.join(self.root, 'leftImg8bit{}'.format('_trainextra.zip'))
                                                 ^
torchvision/datasets/cityscapes.py:141: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                    image_dir_zip = os.path.join(self.root, 'leftImg8bit{}'.format('_trainvaltest.zip'))
                                                 ^
torchvision/datasets/cityscapes.py:144: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                    target_dir_zip = os.path.join(self.root, '{}{}'.format(self.mode, '_trainvaltest.zip'))
                                                  ^
torchvision/datasets/cityscapes.py:146: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                    target_dir_zip = os.path.join(self.root, '{}{}'.format(self.mode, '.zip'))
                                                  ^
torchvision/datasets/cityscapes.py:149: error: Argument "to_path" to "extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Optional[str]" 
[arg-type]
                    extract_archive(from_path=image_dir_zip, to_path=self.root)
                                                                     ^
torchvision/datasets/cityscapes.py:150: error: Argument "to_path" to "extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Optional[str]" 
[arg-type]
                    extract_archive(from_path=target_dir_zip, to_path=self.root)
                                                                      ^
torchvision/datasets/cifar.py:83: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                file_path = os.path.join(self.root, self.base_folder, file_name)
                                         ^
torchvision/datasets/cifar.py:98: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            path = os.path.join(self.root, self.base_folder, self.meta['filename'])
                                ^
torchvision/datasets/cifar.py:136: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                fpath = os.path.join(root, self.base_folder, filename)
                                     ^
torchvision/datasets/cifar.py:145: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str"  [arg-type]
            download_and_extract_archive(self.url, self.root, filename=self.filename, md5=self.tgz_md5)
                                                   ^
torchvision/datasets/celeba.py:134: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                fpath = os.path.join(self.root, self.base_folder, filename)
                                     ^
torchvision/datasets/celeba.py:142: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            return os.path.isdir(os.path.join(self.root, self.base_folder, "img_align_celeba"))
                                              ^
torchvision/datasets/celeba.py:152: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                download_file_from_google_drive(file_id, os.path.join(self.root, self.base_folder), filename, md5)
                                                                      ^
torchvision/datasets/celeba.py:154: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            with zipfile.ZipFile(os.path.join(self.root, self.base_folder, "img_align_celeba.zip"), "r") as f:
                                              ^
torchvision/datasets/celeba.py:155: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                f.extractall(os.path.join(self.root, self.base_folder))
                                          ^
torchvision/datasets/celeba.py:158: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            X = PIL.Image.open(os.path.join(self.root, self.base_folder, "img_align_celeba", self.filename[index]))
                                            ^
torchvision/datasets/caltech.py:57: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            self.categories = sorted(os.listdir(os.path.join(self.root, "101_ObjectCategories")))
                                                             ^
torchvision/datasets/caltech.py:72: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                n = len(os.listdir(os.path.join(self.root, "101_ObjectCategories", c)))
                                                ^
torchvision/datasets/caltech.py:86: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
            img = Image.open(os.path.join(self.root,
                                          ^
torchvision/datasets/caltech.py:96: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]"  [arg-type]
                    data = scipy.io.loadmat(os.path.join(self.root,
                                                         ^
torchvision/datasets/caltech.py:113: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            return os.path.exists(os.path.join(self.root, "101_ObjectCategories"))
                                               ^
torchvision/datasets/caltech.py:125: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
                self.root,
                ^
torchvision/datasets/caltech.py:130: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
                self.root,
                ^
torchvision/datasets/caltech.py:172: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            self.categories = sorted(os.listdir(os.path.join(self.root, "256_ObjectCategories")))
                                                             ^
torchvision/datasets/caltech.py:176: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
                n = len(os.listdir(os.path.join(self.root, "256_ObjectCategories", c)))
                                                ^
torchvision/datasets/caltech.py:188: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            img = Image.open(os.path.join(self.root,
                                          ^
torchvision/datasets/caltech.py:205: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            return os.path.exists(os.path.join(self.root, "256_ObjectCategories"))
                                               ^
torchvision/datasets/caltech.py:217: error: Argument 2 to "download_and_extract_archive" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "str" 
[arg-type]
                self.root,
                ^
torchvision/datasets/kinetics.py:171: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            tar_path = path.join(self.root, "tars")
                                 ^
torchvision/datasets/kinetics.py:172: error: Argument 1 to "join" has incompatible type "Union[str, bytes, _PathLike[Any]]"; expected "Union[str, _PathLike[str]]" 
[arg-type]
            file_list_path = path.join(self.root, "files")
                                       ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants