Having though a bit more about the example, I have to confess, that the checkers work as expected. The 'msg' near the end is not flagged as unused because the 'msg' defined in the case block survives the block, if there would not be the return statement. The checkers do not recognize that but see, that 'msg' is defined and used and that spills over to the other 'msg'.

Am 21.06.26 um 16:32 schrieb Detlev Offenbach:

Hi,

I can confirm, that msg at line 46 is not flagged as unused. The check done by 'pyflakes' does not detect that. I cross checked with 'ruff' and that checker does not detect it either. That is cause by the use of 'msg' in the 'unblock' case block. If you change 'msg' of that block to e.g. msg_1, the 'msg' on line 46 is flagged as expected.

There is nothing I can do about that because if it is an issue, it is outside eric-ide. If two totally different checker packages show the same behavior, than that must be the right one (or both have the identical faulty behavior).

Regards,
Detlev

Am 21.06.26 um 15:47 schrieb Dmitrey Kroshko:
hello, check this code (put it into Eric new file and save)
while it works well with 4-line function myFunction (both variables a and msg are marked as unused), it fails for more complex _operationByMAC (only a is marked as unused and msg is not)

def myFunction(operation = 'lock', macAddress = 'A0:B0:C0:D0:E0:F0'):
    a = 4
    msg = f'operation {operation} with macAddress={macAddress} is finished'
    #print(msg)
    return r

import paramiko

class EmptyClass:
    pass

def _operationByMAC(macAddress=None, operation=None, routerIP = None, userName = None, password = None):
    assert operation in ('unblock', 'block', 'get_state')
    r = EmptyClass()
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    r.ssh = ssh

    ssh.connect(routerIP, username=userName, password=password)
    command = f'ip firewall filter print where src-mac-address="{macAddress}"'
    stdin, stdout, stderr = ssh.exec_command(command)

    result = stdout.read().decode()
    lines = result.split('\n')
    RuleLine  = None
    for line in lines:
        if 'src-mac-address='+macAddress in line:
            RuleLine = line
            break
    if RuleLine is None:
        match operation:
            case 'get_state':
                r.state = 'unblocked'
                print(f'{macAddress} is unblocked')
                return r
            case 'block':
                pass
            case 'unblock':
                msg = 'Error: this MAC was not found in firewall rules'
                print(msg)
                r.msg = msg
                r.state = 'unblocked'
                return r

    a = 3
    msg = f'operation {operation} with macAddress={macAddress} is finished'
    #print(msg)
    return r
Regards, Dmitrey

On Sun, 21 Jun 2026 at 16:12, Detlev Offenbach <[email protected]> wrote:

    Hello Dmitrey,

    I just tried your code over here and have to admit, that
    everything works as expected. The 'msg' variable is flagged as
    unused and an associated message is shown (see attached
    screenshot). Are you sure, that the Syntax Checker Plugin is
    active? You may check this via the Plugin Infos dialog. If it is
    not, just open the context menu in there and selecte 'Activate'.
    If that does not work, check for an error in the associated
    plugin details.

    Regards,
    Detlev

    Am 21.06.26 um 10:16 schrieb Dmitrey Kroshko:
    def myFunc(...):
        ....
        msg = f'operation {operation} with macAddress={macAddress}
    is finished'
        #print(msg)
        return r

-- Detlev Offenbach
    [email protected]

--
Detlev Offenbach
[email protected]

--
Detlev Offenbach
[email protected]

Reply via email to