[flake8-type-checking] Fix false positives for typing.Annotated (#14311)

This commit is contained in:
David Salvisberg 2024-11-13 13:17:52 +01:00 committed by GitHub
parent f789b12705
commit 89aa804b2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 51 additions and 5 deletions

View file

@ -87,6 +87,11 @@ impl ResolvedReference {
.intersects(SemanticModelFlags::DEFERRED_TYPE_DEFINITION)
}
/// Return `true` if the context is in any kind of type definition.
pub const fn in_type_definition(&self) -> bool {
self.flags.intersects(SemanticModelFlags::TYPE_DEFINITION)
}
/// Return `true` if the context is in a type-checking block.
pub const fn in_type_checking_block(&self) -> bool {
self.flags