Closed Mandera closed 1 year ago
Wow! This is some serious black magic, but if that gives us typing and triggers on __eq__
and __hash__
we should go for it! Thanks for the help on this issue :blush:
Got a pretty clean implementation for the dynamic dunders now! I want to make the _inside_typing() function better, the venv structure is different depending on linux vs windows, it's clearly not a robust way to check if call stack goes through the typing module
Perhaps something like inspect.getmodule(frame)
and something from frame.f_globals to prevent false positive from a random package having a typing.py file
Ohh!! Can just do
from inspect import getmodule
import typing
...
if getmodule(frame) is typing:
Closes #30 Closes #31
An experiment, might work. The idea is to make FakeModule hashable only if typing module is in the call stack.
Possibly the best of both worlds. Questionable implementation. Clean up if proceeding!