Uploaded image for project: 'SonarPython'
  1. SonarPython
  2. SONARPY-785

Fix FP on S1764 for expressions in try/except blocks

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1
    • Component/s: None
    • Labels:
      None

      Description

      S1764 raises the following FP on numpy:

      c = cov(x, y, rowvar)
      try:
        d = diag(c)
      except ValueError:
        # nan if incorrect value (nan, inf, 0), 1 otherwise
        return c / c  # FP S1764
      

      To avoid this, S1764 should not raise in try/except blocks, which are more likely to contain such patterns for valid reasons.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                guillaume.dequenne Guillaume Dequenne
                Reporter:
                guillaume.dequenne Guillaume Dequenne
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: