DEV Community

Super Kai (Kazuya Ito)
Super Kai (Kazuya Ito)

Posted on • Edited on

S - Glossary (Python)

Buy Me a Coffee

special type form

  • is a type to do something special within a type hint.
  • is Union, Optional, Concatenate, Literal, etc:
  • basically makes [] required whether strict mode or not in mypy.
  • can also be called special form as used in Python doc but I use special type form because it's more descriptive.

static type

  • is an explicitly written optional type hint checked, or a type inferred by type checkers at pptime.
  • can also be called pptime type but I use static type because it's completely opposite to dynamic type, which is more intuitive.

strict mode

  • means to check strictly.

subtype

  • is a child type which has parent types as supertypes by extending them:
    • Basically, a subtype is accepted by its supertypes but its supertypes aren't accepted by the subtype. For example, bool is a subtype of int so bool is accepted by int but int isn't accepted by bool.
  • can also be called child type but I use subtype because it's shorter.

subtype-like type

  • is a type which isn't actually a subtype of other type but the type is accepted by the other type as if the type is a subtype of the other type. For example, bool isn't actually a subtype of complex and float but bool is accepted by them like bool is a subtype of them so bool is a subtype-like type of complex and float.
  • can also be called child type-like type but I use subtype-like type because it's shorter.

supertype

  • is a parent type which has child types as subtypes by extended by them:
    • Basically, a supertype accepts its subtypes but its subtypes don't accept the supertype. For example, int is a supertype of bool so int accepts bool but bool doesn't accept int.
  • can also be called parent type but I use supertype because it's shorter.

supertype-like type

  • is a type which isn't actually a supertype of other type but the type accepts the other type as if the type is a supertype of the other type. For example, complex isn't actually a supertype of float, int and bool but complex accepts them like complex is a supertype of them so complex is a supertype-like type of float, int and bool.
  • can also be called parent type-like type but I use supertype-like type because it's shorter.

Top comments (0)