@@ -54,8 +54,8 @@ pub use crate::util::diagnostics::add_inferred_python_version_hint_to_diagnostic
5454use crate :: { Db , FxOrderSet , Module , Program } ;
5555pub ( crate ) use class:: { ClassLiteral , ClassType , GenericAlias , KnownClass } ;
5656use instance:: Protocol ;
57- pub ( crate ) use instance:: { NominalInstanceType , ProtocolInstanceType } ;
58- pub ( crate ) use special_form:: SpecialFormType ;
57+ pub use instance:: { NominalInstanceType , ProtocolInstanceType } ;
58+ pub use special_form:: SpecialFormType ;
5959
6060mod builder;
6161mod call;
@@ -511,8 +511,12 @@ pub enum Type<'db> {
511511 /// The set of Python objects that conform to the interface described by a given protocol.
512512 /// Construct this variant using the `Type::instance` constructor function.
513513 ProtocolInstance ( ProtocolInstanceType < ' db > ) ,
514- /// A single Python object that requires special treatment in the type system
514+ /// A single Python object that requires special treatment in the type system,
515+ /// and which exists at a location that can be known prior to any analysis by ty.
515516 SpecialForm ( SpecialFormType ) ,
517+ /// Singleton types that are heavily special-cased by ty, and which are usually
518+ /// created as a result of some runtime operation (e.g. a type-alias statement,
519+ /// a typevar definition, or `Generic[T]` in a class's bases list).
516520 KnownInstance ( KnownInstanceType < ' db > ) ,
517521 /// An instance of `builtins.property`
518522 PropertyInstance ( PropertyInstanceType < ' db > ) ,
@@ -5717,15 +5721,17 @@ impl<'db> TypeMapping<'_, 'db> {
57175721 }
57185722}
57195723
5720- /// Despite its name, this is quite a different type from `NominalInstanceType`.
5721- /// For the vast majority of instance-types in Python, we cannot say how many possible
5722- /// inhabitants there are or could be of that type at runtime. Each variant of the
5723- /// [`KnownInstanceType`] enum, however, represents a specific runtime symbol
5724- /// that requires heavy special-casing in the type system. Thus any one `KnownInstance`
5725- /// variant can only be inhabited by one specific object at runtime.
5724+ /// Singleton types that are heavily special-cased by ty. Despite its name,
5725+ /// quite a different type to [`NominalInstanceType`].
57265726///
5727- /// Conceptually this type is quite similar to `SpecialFormType` and has many similar
5728- /// methods. Unlike that enum, however, this enum's variants are able to wrap associated data.
5727+ /// In many ways, this enum behaves similarly to [`SpecialFormType`].
5728+ /// Unlike instances of that variant, however, `Type::KnownInstance`s do not exist
5729+ /// at a location that can be known prior to any analysis by ty, and each variant
5730+ /// of `KnownInstanceType` can have multiple instances (as, unlike `SpecialFormType`,
5731+ /// `KnownInstanceType` variants can hold associated data). Instances of this type
5732+ /// are generally created by operations at runtime in some way, such as a type alias
5733+ /// statement, a typevar definition, or an instance of `Generic[T]` in a class's
5734+ /// bases list.
57295735///
57305736/// # Ordering
57315737///
@@ -5736,12 +5742,12 @@ impl<'db> TypeMapping<'_, 'db> {
57365742pub enum KnownInstanceType < ' db > {
57375743 /// The type of `Protocol[T]`, `Protocol[U, S]`, etc -- usually only found in a class's bases list.
57385744 ///
5739- /// Note that unsubscripted `Protocol` is represented by [`special_form:: SpecialFormType::Protocol`], not this type.
5745+ /// Note that unsubscripted `Protocol` is represented by [`SpecialFormType::Protocol`], not this type.
57405746 SubscriptedProtocol ( GenericContext < ' db > ) ,
57415747
57425748 /// The type of `Generic[T]`, `Generic[U, S]`, etc -- usually only found in a class's bases list.
57435749 ///
5744- /// Note that unsubscripted `Generic` is represented by [`special_form:: SpecialFormType::Generic`], not this type.
5750+ /// Note that unsubscripted `Generic` is represented by [`SpecialFormType::Generic`], not this type.
57455751 SubscriptedGeneric ( GenericContext < ' db > ) ,
57465752
57475753 /// A single instance of `typing.TypeVar`
0 commit comments