Skip to content

pytest 8.1.0.dev gives TypeError: Warning message must be str #11954

Closed
@pllim

Description

@pllim

Started noticing failures with pytest 8.1.0.dev171+g9454fc38d. I suspect it is caused by #11804 .

In astropy , we have a warning class that is a grandchild of Python built-in Warning class, defined as follows (don't ask me why, I am just the messenger):

class IllegalMinuteWarning(AstropyWarning):
    """
    Raised when a minute value is 60.

    Parameters
    ----------
    minute : int, float
    """

    def __init__(self, minute, alternativeactionstr=None):
        self.minute = minute
        self.alternativeactionstr = alternativeactionstr

    def __str__(self):
        message = (
            f"'minute' was found  to be '{self.minute}', which is not in range [0,60)."
        )
        if self.alternativeactionstr is not None:
            message += " " + self.alternativeactionstr
        return message

Works fine for years, until today. I think pytest type check is now too strict. Is this something you are able to relax a little on your end? Thanks!

Detailed log and more info here:

Metadata

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