Skip to content

Ignore handled exceptions in try blocks #1861

Open
@MusicalNinjaDad

Description

I have the following code which returns as attribute-error unless silenced:

    def __eq__(self, value: object) -> bool:
        """Dice are equal if they give the same probabilities."""
        try:
            return self.probabilities == value.probabilities # pytype: disable=attribute-error
        except AttributeError:
            return False

As handling attribute and type issues is a common case for try: ... except: blocks it would be great if pytype automatically ignored type errors which were specifically handled in the code.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions