Hi all! I'm trying to update our flows to follow b...
# ask-community
s
Hi all! I'm trying to update our flows to follow best practises, but I notice that the official docs don't seem to play play nice when you add type hints. Specifically, if you're using a task runner, type hints cause havoc because of the confusion between a
Future[x]
and
x
itself. Screenshot attached. Has anyone solved this issue?
n
hi @Samuel Hinton - what are you using for static typing?
s
That's just stock standard Pylance that comes with VSCode's default python setup
n
hm this one?
i am not seeing those warnings
although I know prefect with pylance in strict mode has given people grief before
although the warning does make empirical sense, since we resolve the future into the underlying type of the result and anyways hold on, i might have done something to my vscode such that im not seeing those
ah - in fact I did. calling
.result()
on the future removes the complaint but arguably we should do that on our side with some overload
s
From your screenshot, I believe you need to type hint that say_hello returns a string
And then when you pass that into
print_result
it should complain
n
nah i just had a certain type checking flipped off, i repro'd what you showed above
s
Ah, gotcha
n
i'm looking now at our typing overloads on submit to see if we can do something there
👍 1
🙏 1
hmm this is a bit of a rabbit hole in general I will say we don't comply across the board with pylance / mypy in OSS unfortunately, and not to speak for everybody but I'm pretty sure that's more or less an accepted thing for now
perhaps we could open an enhancement ticket to remove our dependence on
ParamSpec
? since that seems like the blocker from proper static typing (at least according to mypy / pyright in the submit / map code)
s
Hmm, I dont have the chops to weight in on the details of ParamSpec and similar things. Im happy to type ignore my code for now, but would you recommend throwing
.result()
around instead (this would make the flow blocking through, right?)