Coding 2023-03-29

Tags:
By Max Woerner Chase

All right...

Let's just do one of these things: the path environment variable work.

Actually, before that, let's see how bad the merge is currently.

...

Not too bad.

Back to the path environment variable stuff.

...

And nearly immediately, I run into trouble.

It was no big deal supporting this at the very bottom level, and I anticipate the levels above will be... mostly workable. What I need to figure out is how to deal with the weird "shapes" that allowing multiple values into the environment mapping is creating. Here's the deal...

The cmd_ wrapper is meant to unwrap values that may be IO-wrapped. (If you know Haskell or a similar language, please try to ignore all possible connotations. They're not the same thing, and if I come up with better terminology, I'll change it.) These values are extract in three different places.

The initial thought that I have is that this implies that the current system of unwrapping doesn't completely make sense. The current system assumes that we can get sensible behavior by passing around streams of values. Now, there's no way around this when it comes to filtering by IO wrapper type, unless whatever alternative system can handle discarding values, but there's no gain in implementing such a system currently.

So, the filtering behavior stands, but the "unwrapping" behavior has to move into a standalone function, and get mapped or comprehended. Let's see...

Okay, I'm going to need to puzzle over that. But I know approximately what comes next:

I'm going to try to get the error fixed, and then call things for tonight.

...

I sort of understand the error, but it... It shouldn't happen?

I just confirmed that it's not because I'm pinning the mypy version back.

In any case, I'm using a cast to deal with this, but really, mypy should just get the right value itself.

Here is a reproduction. My code is extremely normal.

from typing import TypeVar, Union

T = TypeVar("T")

Thing = Union[str, int]

MaybeTuple = Union[T, tuple[T]]

def untuple(item: MaybeTuple[T]) -> T:
    if isinstance(item, tuple):
        return item[0]
    return item

var: MaybeTuple[Thing]

reveal_type(untuple(var))  # object???

I think I'm going to have to live with this at least until I can actually unpin the version, unless there's some way I'm "supposed to" be setting up these unions.

In any case, I want to wrap up for now.

Good night.