Skip to content

not-callable reported when calling a callable returned by non-trivial property #1730

@jendagroovy

Description

@jendagroovy

Steps to reproduce

class ClsA(object):
    pass


class ClsB(object):

    def __init__(self):
        self._some_cls = None

    @property
    def some_cls(self):
        if self._some_cls:
            return self._some_cls

        self._some_cls = ClsA
        return ClsA

    def get_object(self):
        return self.some_cls()

Current behavior

pylint -E /tmp/x.py
************* Module x
E: 19,15: self.some_cls is not callable (not-callable)

Expected behavior

pylint -E /tmp/x.py

No output as the property actually returns a callable. Error should only be reported when there is a certainty, that the property can't return a callable.

pylint --version output

pylint 1.7.4,
astroid 1.5.3
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Control flowRequires control flow understanding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions