PEP 747: TypeExpr: Type Hint for a Type Expression

It seems the opinion of the typing experts vocal in this thread is mainly in favor of the name TypeForm. To paraphrase:

A TypeForm is any of the forms of a type, both common forms (i.e. class objects) and special forms.

  • The reasoning cited is consistent with the reasoning I used originally when suggesting the name TypeForm back in 2020: showing an alignment with the existing term “special form”.
  • Typing experts reasonably argue that “type form” is what the concept is rather than merely how it is spelled, aligning with a preference toward naming the concept for what it is.
  • Several folks don’t seem to find the name collision with the Typeform survey product to be a problem in the long term.

TypeValue is an interesting name, well-contrasted with TypeAlias. However:

  • I don’t think TypeValue is sufficiently distinct from Type. Similarly if I had to choose between List and ListValue, I’d prefer List because it’s shorter and more direct. Sadly the name Type itself is taken.
  • The contrast with TypeAlias isn’t really that important, vs showing a contrast with Type. Additionally TypeAlias is soft-deprecated in favor of the type statement, so showing contrast with a less-and-less used construct will be increasingly less informative to users.

At runtime a variable of TypeForm type would indeed contain a “special form” object if it did not contain a class object. So it is a “form” in that sense. Picking a name that aligns with what the concept is seems desirable.

That’s accurate. However if it’s possible to use a term that better aligns with what the concept is rather than how it is spelled, such a term would be preferred.

Regarding what the concept is:

  • From the perspective of a user, the concept is a “type”.
  • From the perspective of a static type checker, the concept is a “type” (or a “type form”).
  • From the perspective of a runtime type checker the concept is a “type expression” (or a “type form”), whose parts are individually introspected and manipulated.

I prefer the user’s perspective over all others where I’m able to.

2 Likes