Skip to content

Make operator overloading overlapping checks more lenient #1264

Closed
@JukkaL

Description

@JukkaL

Currently the overlapping checks for __add__ / __radd__ and similar make it impossible to have reasonable types for the fractions std lib module (and probably also numbers).

There are several potential related issues:

  • If a base class has a dynamically typed operator method and it gets overridden with an annotated method, mypy may get confused (it shouldn't complain about dynamically typed methods).
  • The overlapping checks should perhaps not complain if multiple inheritance can break type safety, as if we do this we'll have to reject way too much basically valid code (or the checks become so complicated that it's difficult to give useful feedback for users).
  • We'll probably have to allow more flexibility around overriding overloaded functions so that a subclass can introduce new overload variants with fewer restrictions.
  • Overriding methods that use type variables with enumerated values may also be broken in cases where a subclass uses a different set of values.

This is just a placeholder issue -- I'll add more detail later. Perhaps create separate issues for all the above issues.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions