diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 3c701de557..c7c370ed15 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -96,11 +96,11 @@ mod generics; pub mod ide_support; mod infer; mod instance; -mod liskov; mod member; mod mro; mod narrow; mod newtype; +mod overrides; mod protocol_class; mod signatures; mod special_form; diff --git a/crates/ty_python_semantic/src/types/diagnostic.rs b/crates/ty_python_semantic/src/types/diagnostic.rs index 660af238bb..782a25b98e 100644 --- a/crates/ty_python_semantic/src/types/diagnostic.rs +++ b/crates/ty_python_semantic/src/types/diagnostic.rs @@ -18,7 +18,7 @@ use crate::types::class::{ CodeGeneratorKind, DisjointBase, DisjointBaseKind, Field, MethodDecorator, }; use crate::types::function::{FunctionDecorators, FunctionType, KnownFunction, OverloadLiteral}; -use crate::types::liskov::MethodKind; +use crate::types::overrides::MethodKind; use crate::types::string_annotation::{ BYTE_STRING_TYPE_ANNOTATION, ESCAPE_CHARACTER_IN_FORWARD_ANNOTATION, FSTRING_TYPE_ANNOTATION, IMPLICIT_CONCATENATED_STRING_TYPE_ANNOTATION, INVALID_SYNTAX_IN_FORWARD_ANNOTATION, diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index df165921fe..4c97ad8c60 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -109,7 +109,7 @@ use crate::types::{ Truthiness, Type, TypeAliasType, TypeAndQualifiers, TypeContext, TypeQualifiers, TypeVarBoundOrConstraints, TypeVarBoundOrConstraintsEvaluation, TypeVarDefaultEvaluation, TypeVarIdentity, TypeVarInstance, TypeVarKind, TypeVarVariance, TypedDictType, UnionBuilder, - UnionType, UnionTypeInstance, binding_type, infer_scope_types, liskov, todo_type, + UnionType, UnionTypeInstance, binding_type, infer_scope_types, overrides, todo_type, }; use crate::types::{ClassBase, add_inferred_python_version_hint_to_diagnostic}; use crate::unpack::{EvaluationMode, UnpackPosition}; @@ -972,8 +972,9 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { } } - // (8) Check for Liskov violations - liskov::check_class(&self.context, class); + // (8) Check for violations of the Liskov Substitution Principle, + // and for violations of other rules relating to invalid overrides of some sort. + overrides::check_class(&self.context, class); if let Some(protocol) = class.into_protocol_class(self.db()) { protocol.validate_members(&self.context); diff --git a/crates/ty_python_semantic/src/types/liskov.rs b/crates/ty_python_semantic/src/types/overrides.rs similarity index 98% rename from crates/ty_python_semantic/src/types/liskov.rs rename to crates/ty_python_semantic/src/types/overrides.rs index 79b79889fc..0cfc8c477b 100644 --- a/crates/ty_python_semantic/src/types/liskov.rs +++ b/crates/ty_python_semantic/src/types/overrides.rs @@ -1,4 +1,5 @@ -//! Checks relating to the [Liskov Substitution Principle]. +//! Checks relating to invalid method overrides in subclasses, +//! including (but not limited to) violations of the [Liskov Substitution Principle]. //! //! [Liskov Substitution Principle]: https://en.wikipedia.org/wiki/Liskov_substitution_principle