Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Astroid 2.0.1 Regression: Assigning to non slot. #2334

Closed
kayhayen opened this issue Jul 23, 2018 · 1 comment
Closed

Astroid 2.0.1 Regression: Assigning to non slot. #2334

kayhayen opened this issue Jul 23, 2018 · 1 comment

Comments

@kayhayen
Copy link

Steps to reproduce

Code like this:

class NodeBase(NodeMetaClassBase):
    __slots__ = "parent", "source_ref"

    # Avoid the attribute unless it's really necessary.
    if Options.isFullCompat():
        __slots__ += ("effective_source_ref",)

    def setCompatibleSourceReference(self, source_ref):
        """ Bug compatible line numbers information.

            As CPython outputs the last bit of bytecode executed, and not the
            line of the operation. For example calls, output the line of the
            last argument, as opposed to the line of the operation start.

            For tests, we wants to be compatible. In improved more, we are
            not being fully compatible, and just drop it altogether.
        """

        # Getting the same source reference can be dealt with quickly, so do
        # this first.
        if self.source_ref is not source_ref and \
           Options.isFullCompat() and \
           self.source_ref != source_ref:
            # An attribute outside of "__init__", so we save one memory for the
            # most cases. Very few cases involve splitting across lines.
            # pylint: disable=W0201
            self.effective_source_ref = source_ref

As you can see, previously a warning was disabled, because init doesn't assign the attribute, instead of is looked up with getattr(). I am now getting this:

Current behavior

nuitka/nodes/NodeBases.py:273 E0237 assigning-non-slot
NodeBase.setCompatibleSourceReference Assigning to attribute
'effective_source_ref' not defined in class slots
nuitka/nodes/NodeBases.py:272 I0021 useless-suppression Useless
suppression of 'attribute-defined-outside-init'

Expected behavior

Seems support for "slots" was added in there, but my form of calculating slots is not understood, but of course it ought to be. No warning should be given.

pylint --version output

python3.6 -m pylint --version
main.py 2.0.0
astroid 2.0.1
Python 3.6.3 (default, Mar 27 2018, 00:29:24)
[GCC 6.3.0 20170516]

@PCManticore
Copy link
Contributor

Thanks for the report, I can confirm this is not working anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants