Coding 2023-04-20

Tags:
By Max Woerner Chase

I'm going to try and get Mypy unpinned. Let's see what kind of shape it's in...

(motr-dev) ↪ hg diff
diff --git a/requirements/mypy.txt b/requirements/mypy.txt
--- a/requirements/mypy.txt
+++ b/requirements/mypy.txt
@@ -1,3 +1,3 @@
 lxml
-mypy<1 # My weird code.
+mypy
 trio-typing

And when I run motr -t mypy, it

src/motr/_api/cli_types/parametric.py:512: error: Argument "instantiate" to "evolve" of "Parametric[T]" has incompatible type "Callable[[PerItemParametricMapping[motr._api.cli_types.box._Unlabel], PerItemParametricMapping[motr._api.cli_types.selection._Unlabel]], Generator[Union[Action, ActionInput, ActionOutput, TargetName, SkippedName], None, T]]"; expected "Callable[[PerItemParametricMapping[motr._api.cli_types.box._Unlabel], PerItemParametricMapping[motr._api.cli_types.selection._Unlabel]], Generator[Union[Action, ActionInput, ActionOutput, TargetName, SkippedName], None, T_co]]"  [arg-type]

It

src/motr/_api/cli_types/parametric.py:512: error: Argument "instantiate" to "evolve" of "Parametric[T]" has incompatible type "Callable[[PerItemParametricMapping[motr._api.cli_types.box._Unlabel], PerItemParametricMapping[motr._api.cli_types.selection._Unlabel]], Generator[Union[Action, ActionInput, ActionOutput, TargetName, SkippedName], None, T]]"; expected "Callable[[PerItemParametricMapping[motr._api.cli_types.box._Unlabel], PerItemParametricMapping[motr._api.cli_types.selection._Unlabel]], Generator[Union[Action, ActionInput, ActionOutput, TargetName, SkippedName], None, T_co]]"  [arg-type]

I mean, I think that sounds straight-up incorrect, but

src/motr/_api/cli_types/parametric.py:512: error: Argument "instantiate" to "evolve" of "Parametric[T]" has incompatible type "Callable[[PerItemParametricMapping[motr._api.cli_types.box._Unlabel], PerItemParametricMapping[motr._api.cli_types.selection._Unlabel]], Generator[Union[Action, ActionInput, ActionOutput, TargetName, SkippedName], None, T]]"; expected "Callable[[PerItemParametricMapping[motr._api.cli_types.box._Unlabel], PerItemParametricMapping[motr._api.cli_types.selection._Unlabel]], Generator[Union[Action, ActionInput, ActionOutput, TargetName, SkippedName], None, T_co]]"  [arg-type]

Fiiiiine.

So, about two weeks ago, Mypy got another release, and I got more errors. With some experimentation on a reproduction that doesn't recite the entire text of Moby Dick, I've determined that it's probably fine if the following two conditions are met:

There is no way that second one is intended behavior. Ludicrous. The first one is a little obnoxious, but I'm not confident that that wasn't intended? Anyway, let's see what I need to handle this...

Okay, wait. Hold on. It instantiated the constraints on a typevar, then failed to unify the typevar with the constraints? Okay.

Okay.

Okay.

Okay.

Okay.

Okay.

I've got to file this, because that is actually impossible to satisfy.

So, I guess I can consider trying to move the pin out, but I'm frankly not impressed by how Mypy 1+ has handled MOTR's code. Kind of weird how the scrunkly plugin stuff hasn't posed any obvious problems, but whatever.

Anyway, getting all het up about how messed up the new evolve() handling is ate up the night, so I guess I'm not doing this. And I'm kind of skeptical about whether it's worth trying to get to 1.1+.

I'm going to wrap things up for now, and see what I'm up for later.

Good night.