Skip to content

mypy base class compatibility #3

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

Closed
jeremander opened this issue Jan 13, 2025 · 2 comments
Closed

mypy base class compatibility #3

jeremander opened this issue Jan 13, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@jeremander
Copy link
Owner

jeremander commented Jan 13, 2025

There's some quirk in the definition of TextSerializable which causes mypy to error when inheriting from it along with some other base class.

Minimal example:

from fancy_dataclass.serialize import TextFileSerializable

class Mixin:
    pass

class A(TextFileSerializable):
    pass

class B(Mixin, TextFileSerializable):
    pass

Running mypy (version 1.14.1), I get:

error: Definition of "_from_bytes" in base class "TextSerializable" is incompatible with definition in base class "BinaryFileSerializable"  [misc]
error: Definition of "_to_bytes" in base class "TextSerializable" is incompatible with definition in base class "BinaryFileSerializable"  [misc]

The error only occurs on B, not A. My guess is that the type: ignore statement on TextFileSerializable (suppressing the error about incompatible method definitions) carries over to simple inheritance but not multiple inheritance.

Not sure if this is a bug in mypy or not, but ideally the method signatures could be fixed to be compatible.

@jeremander
Copy link
Owner Author

See also: python/mypy#18458

@jeremander
Copy link
Owner Author

Fixed as of 6f67d1a.

@jeremander jeremander added the bug Something isn't working label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant