Skip to content

Clean up kludges for handling metaclasses and Type[...] in check_op_reversible #5491

Closed
@Michael0x2a

Description

@Michael0x2a

The current implementation for checking reversible operators contains two kludges that seem to be related to operators, metaclasses, and Type[...]

  1. This call to has_member feels like it ought to be unnecessary/redundant due to the following analyze_member_access -- but removing it causes pythoneval's OpMetaclassAccess test case to fail.

    (Note: if you remove just that call, you also need to add in a elif isinstance(member, AnyTyp): return None after calling analyze_member_access)

  2. If the reversible operators logic was unable to find a matching operator, it just tries calling check_call on the name directly to get back some generic error message. It seems as if this call ought to always return an error message, but sometimes it surprisingly will not. E.g. see the TypeTypeComparisonWorks tests in check-classes -- adding an assert local_errors.is_errors() causes that test case to crash.

    This feels related to the first TODO in some way -- either we're not handling operators + metaclasses + Type directly, or there are some weird shenanigans happening due to Any...

For additional context, see #5136 and #1806.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions