这是indexloc提供的服务,不要输入任何密码
Skip to content

S507 does not trigger when using class inheritance #21407

@schnow265

Description

@schnow265

Summary

When creating a class which inherits from paramiko.SSHClient and then using self.set_missing_host_key_policy(paramiko.AutoAddPolicy), the linter rule is not triggered. The same applies when creating an instance of the custom class and calling the function there.

I have included an example:

import paramiko

ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy)  # triggers rule


class Test(paramiko.SSHClient):
    def __init__(self):
        super().__init__()
        self.set_missing_host_key_policy(paramiko.AutoAddPolicy)  # does not trigger rule

client = Test()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy)  # also doesn't trigger rule

You can check it by pasting my python snippet into a file and then using the following command:

ruff check --select S507 ./path/to/file.py

Version

ruff 0.14.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions