0

I have code that looks like this:

def _check(self) -> None:
    cars = self.cars.all()
    cars.sort(key=self.key)
    names: Set[str] = set()

Can someone explain to me what the code names: Set[str] = set() is doing?

Alan2
  • 23,493
  • 79
  • 256
  • 450

1 Answers1

2

This is an initialisation with a type hint. It declares that the type of the variable names is a set type with string values, which is initialised to an empty set (= set()).

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214