ugh how do I tell codecov that a python match/case statement is exhaustive without a default case

all 6 comments

sorted by: hot top controversial new old
[–] [S] 1 point 1 day ago*

okay I guess if I want to be runtime-hygienic about this I should use a multi-line exclusion coverage.readthedocs.io/en/7.1 like "case _:\n\s*assert False"

  • source
  • [–] 1 point 1 day ago

    @glyph you tell it to fuck off :p(does it have a "skip" marker?)

  • source
  • [–] 1 point 1 day ago (2 children)

    @glyph um do what I consider best practice in any language and put a default with a throw in it for when future you adds a state but not a case? well that's what I always do anyway. 🤷‍♀️😺

  • source
  • hideshow 2 child comments
  • [–] [S] 1 point 1 day ago (1 child)

    @tekhedd the trouble is that eventually my type checker is going to fight with my coverage checker about this

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 1 day ago

    @glyph heh, I was just thinking that, yes coverage tool will complain about that. there's no way to test a line whose only purpose is to fail hard because it should not be reachable. options include annotating it for the coverage tester or.. ugh.. somehow injecting a test case to trigger it which..is ugly. yeah. sorry.this should be part of the language, I think. "unreachable_default:"

  • source
  • parent
  • [–] 1 point 1 day ago

    @glyph just default assert("no")

  • source