typing and typechecks updates#4722
Merged
vladmandic merged 14 commits intovladmandic:devfrom Apr 2, 2026
Merged
Conversation
- ResScripts - ResEmbeddings
Only tuples support typing a specific number of entries.
Type safe, avoids redefining parameter types, and the static type checker is able to parse it easily.
Not sure why, but it was causing errors
Owner
|
changes look sane to me. not a huge fan of walrus usage in grid size - nothing wrong with it, but it makes it difficult to read/understand upon first look. |
Contributor
Author
|
Sounds good to me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A partial set of various updates that I'm sending through because another upcoming update would probably be better off as its own PR but it builds off of a few of these updates.
ResScriptsResEmbeddingsResGPU(lists don't support sized typing, only tuples do).namedtupleto typedNamedTuple.ScriptFileScriptClassDataGridsd_unet.pyandsd_model.py(separate from the PEP 484 update this time).pis actuallyNoneinstead of relying on acopyparameter that's never used (and its only use was to get the same behavior, but not in a way that was type-safe or made sense).get_grid_sizeto work better with static type checkers.tuple[int, int]return type.Side note: I have no idea why, but for some reason the script would be listed as invalid and the
namelisted as "unknown" when using the direct import formatfrom modules.scripts_postprocessing import PostprocessedImage, ScriptPostprocessinginstead offrom modules import scripts_postprocessingand accessing them as attributes.