parsec-cloud icon indicating copy to clipboard operation
parsec-cloud copied to clipboard

Harden pyRight configuration

Open FirelightFlagboy opened this issue 1 year ago • 1 comments

Each commit enable a new rule with it's required change

FirelightFlagboy avatar Mar 14 '24 13:03 FirelightFlagboy

@vxgmichel pyright is now configured with:

  • reportMatchNotExhaustive which require match to catch all possible case.

    That correspond to the pattern

    foo: bool
    match foo:
      case True:
        pass
      case _: # False is not tested
        pass
    

    previously we had:

    match timestamps_in_the_ballpark(s_data.timestamp, now):
      case TimestampOutOfBallpark() as error:
        return error
    

    Here the case None isn't tested

  • reportUnnecessaryComparison which signal when we are doing useless comparison

    For if branch:

    foo = True
    if foo == False: # unnecessary
      pass
    

    For match:

    foo: bool
    match foo:
      case True:
         pass
      case False:
         pass
      case _: # impossible, all case are tested
         pass
    

FirelightFlagboy avatar Mar 14 '24 13:03 FirelightFlagboy