eyurtsev / eyurtsev/fcsparser

Issue : Incorrect usage of `warnings.warn` with formatted strings

Open
#79 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
84
Forks
51
PR merge metrics
No merged PRs in 30d

Description

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:

```python
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:
```python
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.