PyHamcrest icon indicating copy to clipboard operation
PyHamcrest copied to clipboard

fixing mypy's Matcher[Never]

Open bukzor opened this issue 6 months ago • 5 comments

The idea is that manually unrolling these Union[Matcher[T], T] alternatives into @overload alternatives allows mypy to properly evaluate them in order, rather than getting confused and giving up (resulting in an inference of T = Never).

Closes: #266 #264

Two off-topic changes included: (you can revert them or ask me to)

  • uv sync will now treat PyHamcrest[dev] as its dev "dependency group"
  • full typing for the implementation of has_entries

bukzor avatar Jun 24 '25 19:06 bukzor

draft: adding some quick typechecking tests

bukzor avatar Jun 24 '25 19:06 bukzor

Looks like we'd need to remove 3.8 support to make this work, which I am fine with.

brunns avatar Jun 25 '25 07:06 brunns

3.8 compat restored. All type annotations regression tested (they fail with the "Matcher[Never]" error at HEAD, mostly).

bukzor avatar Jun 25 '25 18:06 bukzor

Ready for merge, to the best of my ability.

bukzor avatar Jul 01 '25 21:07 bukzor

happy monday!

bukzor avatar Jul 14 '25 14:07 bukzor