-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup and organize utils #7033
Conversation
✅ Deploy Preview for frigate-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
maybe, simplify this by use https://github.com/scientific-python/lazy_loader ? |
actually, this doesn't work the way I thought it did. And as far as I can tell it breaks the code completion / type checking in vscode |
can you provide an example? |
As this PR is now vscode recognizes the function and ctrl + clicking it opens that function, also will warn if incorrect parameters are supplied to the function When trying to use lazy loading based on their readme, it does not recognize the functions.
It is possible it could be some cache thing or something but I did restart vscode and also ran frigate. Frigate worked as expected but the issue above remained. |
Are you sure you didn't forget to create appropriate .pyi files? |
Ah, I saw type checkers but figured that would just be for mypy, I now see that it also applies to IDEs which makes sense. I will try this later and I expect that it will most likely solve the issue |
Okay it is working now but I am unsure this really makes things any simpler, it will now require adding each function that is added to any util in the __all__ = ['EventsPerSecond', ' clean_camera_user_pass', ' deep_merge', ' escape_special_characters', ' get_ffmpeg_arg_list', ' get_tz_modifiers', ' load_config_with_no_duplicates', ' load_labels', ' to_relative_box']
from .builtin import EventsPerSecond, clean_camera_user_pass, deep_merge, escape_special_characters, get_ffmpeg_arg_list, get_tz_modifiers, load_config_with_no_duplicates, load_labels, to_relative_box and you will still have to use I think something like this may be worth doing in the future but this PR is meant to be a simple reorganization effort there will already be benefit to improved importing since the entire set of utils no longer need to be imported |
maybe, something like: import inspect
import .builtin as builtin_module
__all__ = [name for name, obj in inspect.getmembers(builtin_module) if not name.startswith('_') and (inspect.isfunction(obj) or inspect.isclass(obj))] |
Yea. I don't see enough of a benefit for automatic imports. Breaks the navigation in github too. Just a few conflicts to resolve now. |
The util class was getting a bit unwieldy, I think it is good to organize the utils at this point