You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: useless_with_lock.rs
    path of file: ./repos/ruff/crates/ruff_linter/src/rules/pylint/rules
    
    the code of the file until where you have to start completion: use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::{self as ast};
use ruff_text_size::Ranged;

use crate::checkers::ast::Checker;

/// ## What it does
/// Checks for direct uses of lock objects in `with` statements.
///
/// ## Why is this bad?
/// Creating a lock (via `threading.Lock` or similar) in a `with` statement
/// has no effect, as locks are only relevant when share
    
pub(crate) fn useless_with_lock(checker: &mut Checker, with: &ast::StmtWith) {
    for item in &with.items {
        let Some(call) = item.context_expr.as_call_expr() else {
            continue;
        };

        if !checker
            .semantic()
            .resolve_qualified_name(call.func.as_ref())
            .is_some_and(|qualified_name| {
                matches!(
                    qualified_name.segments(),
                    [
                        "threading",
                        "Lock" | "RLock" | "Condition" | "Semaphore" | "BoundedSemaphore"
                    ]
                )
            })
        {
            return;
        }

        checker
            .diagnostics
            .push(Diagnostic::new(UselessWithLock, call.range()));
    }
}