Skip to content

[mypyc] support of @final types #9612

Closed

Description

@sobolevn

Bug Report

I am trying to compile a module with @final types.
This does not seem possible at the moment with mypyc.

Actual source: https://github.com/dry-python/returns/blob/master/returns/result.py#L312

To Reproduce

from typing_extensions import final


class Base(object):
    """Can be sub-classed."""


@final
class Child(Base):
    """Final instance."""

When mypyc is used on top of this code, this happens:

» mypyc ex.py
ex.py:9: error: Non-extension classes may not inherit from extension classes

As I understand, mypyc treats @final as a regular decorator and then makes Child a non-exntesion class.
And this does not seem correct to me.

Expected Behavior

I would expect this code to compile without any warnings.
And @final should be treated the same way mypy does with regular python code.

  • Mypy version used: 0.790

Activity

  1. jairov4 commented on Apr 21, 2024

    @jairov4
    Contributor

    still happening in 1.0.9
    even I think it would be benefical for codegen to apply optimization

  2. added a commit that references this issue on Oct 14, 2024
    cbd96f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions