Skip to content

Issue : Incorrect usage of warnings.warn with formatted strings #79

Description

@PrinceSajjadHussain

The warnings.warn function should be called with the stacklevel parameter to provide more accurate information about the source of the warning. Also, the message should be passed directly instead of using format. This will allow tools to filter based on warning type instead of message.

Consider the following updates to the read_header method:

        if header["analysis end"] - header["analysis start"] != 0:
            warnings.warn(
                "There appears to be some information in the ANALYSIS segment of file "
                "{0}. However, it might not be read correctly.".format(self.path),
                stacklevel=2,
            )

should be changed to:

        if header["analysis end"] - header["analysis start"] != 0:
            warnings.warn(
                "There appears to be some information in the ANALYSIS segment of file {0}. However, it might not be read correctly.".format(self.path),
                stacklevel=2,
            )

This issue exists elsewhere in the code, such as in FCSParser._extract_text_dict and should be updated consistently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions