简体   繁体   中英

PEP8 mark the variable reference @pytest.fixture as “shadows name from outer scope”

I have one simple pytest problem,:

import pytest

@pytest.fixture
def config():
    return "abc"

def mytest(config):
    print(config)

The message mentioned that "Shadows name 'config' from out scope" in the line of def mytest(config): .

Any suggestion to handle this PEP8 message?

Depending on who is raising the warning, it can be suppressed like:

Suppress pylint warning:

# pylint: disable=R0801
def mytest(x_config):
    print(x_config)

Suppress pycharm warning:

# noinspection 801,PyShadowingNames
def mytest(x_config):
    print(x_config)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM