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

Regression in version 7.6.0 when base class name has more than one level of nesting #121

Closed
CastorAF opened this issue Jan 23, 2024 · 3 comments
Labels

Comments

@CastorAF
Copy link

Hello,
Release 7.6.0 has broken code where the base class is qualified by several parent classes or modules:

import logging.handlers

from overrides import overrides

# OK with overrides 7.5.0, throws at import with 7.6.0!
class MyHandler(logging.handlers.WatchedFileHandler):
    @overrides
    def reopenIfNeeded(self):
        pass


class Nest:
    class First:
        class Second:
            def foo(self):
                pass


# OK with overrides 7.5.0, throws at import with 7.6.0!
class ChildOfNested(Nest.First.Second):
    @overrides
    def foo(self):
        pass

NOTE: it works fine with one single level of qualification (e.g. some_module.SomeClass or Outer.InnerClass)

This was working fine with version 7.5.0, but is failing with version 7.6.0 with error "No super class method found" (tested with python 3.9 .7 and 3.11.3 with same error, on Linux).

The regression comes from this change (diff -213/+218 of overrides/overrides.py in changeset 444a7a5): if I comment both checks on extends, I get back the previous behavior. However, that change was probably done for a reason, and I don't master bytecode disassembly so I can't really propose a fix...

It's easy to work around (see below), but not trivial to figure out what's wrong! If you can have a look at it, it would be great!

Thanks in advance,
Rémi

NOTE: Possible workarounds corresponding to previous snippet:

from logging.handlers import WatchedFileHandler

from overrides import overrides

# workaround: use unqualified name for the base class
class MyHandler(WatchedFileHandler):
    @overrides
    def reopenIfNeeded(self):
        pass


class Nest:
    class First:
        class Second:
            def foo(self):
                pass

# workaround: alias the nested type to an unqualified name
NestFirstSecond = Nest.First.Second
class ChildOfNested(NestFirstSecond):
    @overrides
    def foo(self):
        pass
mr-cal added a commit to canonical/craft-parts that referenced this issue Jan 23, 2024
See mkorpela/overrides#121

Signed-off-by: Callahan Kovacs <[email protected]>
Co-authored-by: Alex Lowe <[email protected]>
mr-cal added a commit to canonical/craft-parts that referenced this issue Jan 23, 2024
See mkorpela/overrides#121

Signed-off-by: Callahan Kovacs <[email protected]>
Co-authored-by: Alex Lowe <[email protected]>
@mkorpela
Copy link
Owner

Thank you for the report!

lengau added a commit to canonical/craft-parts that referenced this issue Jan 24, 2024
@mkorpela mkorpela added the bug label Jan 24, 2024
@mkorpela
Copy link
Owner

Can reproduce and added the case to main branch. Thank you again. I'll work on this asap also contributions are much appreciated.

@mkorpela
Copy link
Owner

Regression fixed in 7.7.0.

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Jan 31, 2024
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Feb 7, 2024
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants