facebookresearch / ClassyVision

An end-to-end PyTorch framework for image and video classification
https://classyvision.ai
MIT License
1.59k stars 278 forks source link

Use generic types in type checking #720

Closed yiwen-song closed 3 years ago

yiwen-song commented 3 years ago

Summary: Background: https://fb.workplace.com/groups/349226332644221/permalink/776593166574200/

According to the suggestion, we make the following changes in the classy vision codebase (only for the type checking part):

  1. type(x) == list or tuple -> isinstance(x, Typing.Sequence)
  2. type(x) == dict -> isinstance(x, Typing.Mapping)

Differential Revision: D27170968