Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

pylint error, R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) #844

Open
qwordy opened this issue May 11, 2021 · 0 comments
Assignees
Labels
priority_p1_important important but not blocking

Comments

@qwordy
Copy link
Member

qwordy commented May 11, 2021

Generated code has a Python style error.

C:\yfy\azure-cli-extensions\src\cloudservice\azext_cloudservice\tests\__init__.py:57:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)

Source code:

    def wrapper(*args, **kwargs):
        func_to_call = get_func_to_call()
        logger.info("running %s()...", func.__name__)
        try:
            test_map[func.__name__] = dict()
            test_map[func.__name__]["result"] = SUCCESSED
            test_map[func.__name__]["error_message"] = ""
            test_map[func.__name__]["error_stack"] = ""
            test_map[func.__name__]["error_normalized"] = ""
            test_map[func.__name__]["start_dt"] = dt.datetime.utcnow()
            ret = func_to_call(*args, **kwargs)
        except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit,
                JMESPathCheckAssertionError) as e:
            use_exception_cache = os.getenv("TEST_EXCEPTION_CACHE")
            if use_exception_cache is None or use_exception_cache.lower() != "true":
                raise
            test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
            test_map[func.__name__]["result"] = FAILED
            test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500]
            test_map[func.__name__]["error_stack"] = traceback.format_exc().replace(
                "\r\n", " ").replace("\n", " ")[:500]
            logger.info("--------------------------------------")
            logger.info("step exception: %s", e)
            logger.error("--------------------------------------")
            logger.error("step exception in %s: %s", func.__name__, e)
            logger.info(traceback.format_exc())
            exceptions.append((func.__name__, sys.exc_info()))
        else:
            test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
            return ret
@qwordy qwordy added the priority_p1_important important but not blocking label May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority_p1_important important but not blocking
Projects
None yet
Development

No branches or pull requests

3 participants