How to specify that an attribute must be a list of (say) integers, not just a list?
问题 Using the attrs libary and Python 3.6, I thought the following would allow me to specify that x and y can only contain integers: import attr @attr.s class C: x : List[int] = attr.ib() # not working y = attr.ib(type=List[int]) # not working either Both of the commented lines throw a NameError: name 'List' is not defined . The reasons I expected that to work are these: (1) The types section of the attr documentation includes the following passage: " attrs also allows you to associate a type