the tuple comprehension in def f() is wrong (or I guess generator expression)
You get a generator object, because the code in the expression (I guess generator expression) is not yet evaluated. This is why you haven’t gotten any exceptions yet.
Write your print(f()) as print(list(f()) and you’ll see you are having errors in your expression.
Again, it is unclear what you are trying to do: the code for f() is incorrect, obtuse and hard to read.
Your set comprehension has at least the correct syntax compared to the generator expression.
FWIW, writing code is a dialog with future readers. It is your job to make it clear and easy to understand.
Anyway, right now AI creates crap code. Maybe some day in the future it generates usable code, but not right now. Don’t use it as is, especially if you don’t fully understand what the generated code does.