Closed simonw closed 2 months ago
This took longer than expected because I got stuck on a gnarly bug, which I eventually resolved using OpenAI's o1-preview
:
files-to-prompt **/*.py -c | llm -m o1-preview "
The middleware test is failing showing all ogf these - why is MiddlewareAfter repeated so many times?
['MiddlewareAfter', 'Middleware3', 'MiddlewareAfter', 'Middleware5', 'MiddlewareAfter', 'Middleware3', 'MiddlewareAfter', 'Middleware2', 'MiddlewareAfter', 'Middleware3', 'MiddlewareAfter', 'Middleware5', 'MiddlewareAfter', 'Middleware3', 'MiddlewareAfter', 'Middleware4', 'MiddlewareAfter', 'Middleware3', 'MiddlewareAfter', 'Middleware5', 'MiddlewareAfter', 'Middleware3', 'MiddlewareAfter', 'Middleware2', 'MiddlewareAfter', 'Middleware3', 'MiddlewareAfter', 'Middleware5', 'MiddlewareAfter', 'Middleware3', 'MiddlewareAfter', 'Middleware', 'MiddlewareBefore']"
https://gist.github.com/simonw/03776d9f80534aa8e5348580dc6a800b
Just a thought, but I am wondering if the item cannot be found if it should throw an error or automatically put the middleware at the beginning/end of the list. I have a use case where a plugin should be before another plugin if it's installed. if that other plugin is not installed it can be somewhere else. Users don't always have that other plugin installed.
Maybe adding a default position like nulls_last
, or pass it a flag to not raise an error if it's not found?
I haven't tried it, but maybe I can also implement my conditional ordering logic in the function itself?
@djp.hookimpl
def middleware():
@carltongibson suggested that middleware be able to say "I should be run directly before/after this other named middleware".