Coding 2023-03-29
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 Cmd constructor needs the same structure, but with all wrapping discarded, and individual values passed through os.fspath. The changes I just made make the structure more complex, and move around the concept of "individual values".
- The action (I assume this has a different name in the future topic, but I've forgotten) call needs the stream of individual values, as does the _extra_targets call.
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...
- Write the unwrap function...
- Use the unwrap function in cmd_
- Remove the method...
- Fix a mypy error that I introduced somehow...
Okay, I'm going to need to puzzle over that. But I know approximately what comes next:
- Write a function to emit all "individual values" from one of these fancy environment dictionaries.
- Write a function to map over one of these fancy environment dictionaries.
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.