-
Notifications
You must be signed in to change notification settings - Fork 2
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
IO maps #559
Conversation
Signed-off-by: liamhuber <[email protected]>
The method is in-place Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
* Use typing.Callable instead of callable Signed-off-by: liamhuber <[email protected]> * Ignore erroneous error typing._UnionGenericAlias definitively _does_ exist. Signed-off-by: liamhuber <[email protected]> * Hint a tuple, don't return one Signed-off-by: liamhuber <[email protected]> * Hint typing.Callable instead of callable Signed-off-by: liamhuber <[email protected]> * Expose the Self typing tool for all versions Signed-off-by: liamhuber <[email protected]> * Add a mypy job Based on @jan-janssen's jobs for other pyiron repos Signed-off-by: liamhuber <[email protected]> * `mypy` channels (#534) * Leverage generics for connection partners Signed-off-by: liamhuber <[email protected]> * Break apart connection error message So we only reference type hints when they're there Signed-off-by: liamhuber <[email protected]> * Hint connections type more specifically Signed-off-by: liamhuber <[email protected]> * Hint disconnect more specifically Signed-off-by: liamhuber <[email protected]> * Use Self in disconnection hints Signed-off-by: liamhuber <[email protected]> * Use Self to hint value_receiver Signed-off-by: liamhuber <[email protected]> * Devolve responsibility for connection validity Otherwise mypy has trouble telling that data channels really are operating on a connection partner, since the `super()` call could wind up pointing anywhere. Signed-off-by: liamhuber <[email protected]> * Fix typing in channel tests Signed-off-by: liamhuber <[email protected]> * 🐛 Return the message Signed-off-by: liamhuber <[email protected]> * Fix typing in figuring out who is I/O Signed-off-by: liamhuber <[email protected]> * Recast connection parters as class method mypy complained about the class-level attribute access I was using to get around circular references. This is a bit more verbose, but otherwise a fine alternative. Signed-off-by: liamhuber <[email protected]> * Match Accumulating input signal call to parent Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Move Ruff jobs into the main push-pull script This is just a little QoL thing; the current script runs the jobs twice every time I push, and it's annoying me. Signed-off-by: liamhuber <[email protected]> * Ruff: import Callable from collections.abc Signed-off-by: liamhuber <[email protected]> * black Signed-off-by: liamhuber <[email protected]> * Drop the private type hint (#535) It was necessary for python<3.10, but we dropped support for that, so we can get rid of the ugly, non-public hint. Signed-off-by: liamhuber <[email protected]> * `mypy` channels redux (#536) * Refactor: rename Move from "partner" language to "conjugate" language Signed-off-by: liamhuber <[email protected]> * Explicitly decompose conjugate behaviour Into flavor and IO components Signed-off-by: liamhuber <[email protected]> * Tidying Signed-off-by: liamhuber <[email protected]> * Narrow hint on connection copying Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Apply hints to IO panels (#537) * Refactor: rename Move from "partner" language to "conjugate" language Signed-off-by: liamhuber <[email protected]> * Explicitly decompose conjugate behaviour Into flavor and IO components Signed-off-by: liamhuber <[email protected]> * Tidying Signed-off-by: liamhuber <[email protected]> * Narrow hint on connection copying Signed-off-by: liamhuber <[email protected]> * Apply hints to IO panels Signed-off-by: liamhuber <[email protected]> * Narrow type Signed-off-by: liamhuber <[email protected]> * Don't reuse variable Signed-off-by: liamhuber <[email protected]> * Ruff: sort imports Signed-off-by: liamhuber <[email protected]> * 🐛 fix type hint Signed-off-by: liamhuber <[email protected]> * Add more hints Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Refactor connection validity The instance check to see if a connection candidate has the correct (conjugate) type now occurs only _once_ in the parent `Channel` class. `Channel._valid_connection` is the repurposed to check for validity inside the scope of the classes already lining up, and defaults to simply returning `True` in the base class. `DataChannel` overrides it to do the type hint comparison. Changes inspired by [conversation](#533 (comment)) with @XzzX. Signed-off-by: liamhuber <[email protected]> * `mypy` run (#541) * Hint init properties Signed-off-by: liamhuber <[email protected]> * Hint local function Signed-off-by: liamhuber <[email protected]> * Add stricter return and hint Signed-off-by: liamhuber <[email protected]> * 🐛 Hint tuple[] not () Signed-off-by: liamhuber <[email protected]> * Black Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * `mypy` topology and find (#542) * Don't overload typed variable Signed-off-by: liamhuber <[email protected]> * Add (and more specific) return hint(s) To the one function missing one Signed-off-by: liamhuber <[email protected]> * Add module docstring Signed-off-by: liamhuber <[email protected]> * Catch module spec failures Signed-off-by: liamhuber <[email protected]> * Force mypy to accept the design feature That we _want_ callers to be able to get abstract classes if they request them Signed-off-by: liamhuber <[email protected]> * Black Signed-off-by: liamhuber <[email protected]> * Ruff import sort Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * `mypy` semantics (#538) * Initialize _label to a string Signed-off-by: liamhuber <[email protected]> * Hint the delimiter Signed-off-by: liamhuber <[email protected]> * Make SemanticParent a Generic Signed-off-by: liamhuber <[email protected]> * Purge `ParentMost` If subclasses of `Semantic` want to limit their `parent` attribute beyond the standard requirement that it be a `SemanticParent`, they can handle that by overriding the `parent` setter and getter. The only place this was used was in `Workflow`, and so such handling is now exactly the case. Signed-off-by: liamhuber <[email protected]> * Update comment Signed-off-by: liamhuber <[email protected]> * Use generic type Signed-off-by: liamhuber <[email protected]> * Don't use generic in static method Signed-off-by: liamhuber <[email protected]> * Jump through mypy hoops It doesn't recognize the __set__ for fset methods on the property, so my usual routes for super'ing the setter are failing. This is annoying, but I don't see it being particularly harmful as the method is private. Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Add dev note Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Semantics generic parent (#544) * Make SemanticParent a Generic Signed-off-by: liamhuber <[email protected]> * Don't use generic in static method Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Remove HasParent An interface class guaranteeing the (Any-typed) attribute is too vague to be super useful, and redundant when it's _only_ used in `Semantic`. Having a `parent` will just be a direct feature of being semantic. Signed-off-by: liamhuber <[email protected]> * Pull out static method Signed-off-by: liamhuber <[email protected]> * Pull cyclicity check up to Semantic Signed-off-by: liamhuber <[email protected]> * De-parent SemanticParent from Semantic Because of the label arg vs kwarg problem, there is still a vestigial label arg in the SemanticParent init signature. Signed-off-by: liamhuber <[email protected]> * Remove redundant type check This is handled in the super class Signed-off-by: liamhuber <[email protected]> * Give Semantic a generic parent type Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Black Signed-off-by: liamhuber <[email protected]> * Ruff sort imports Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Update docstrings Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Improvements to semantic labeling (#547) * Initialize _label to a string Signed-off-by: liamhuber <[email protected]> * Hint the delimiter Signed-off-by: liamhuber <[email protected]> * Make SemanticParent a Generic Signed-off-by: liamhuber <[email protected]> * Purge `ParentMost` If subclasses of `Semantic` want to limit their `parent` attribute beyond the standard requirement that it be a `SemanticParent`, they can handle that by overriding the `parent` setter and getter. The only place this was used was in `Workflow`, and so such handling is now exactly the case. Signed-off-by: liamhuber <[email protected]> * Update comment Signed-off-by: liamhuber <[email protected]> * Use generic type Signed-off-by: liamhuber <[email protected]> * Don't use generic in static method Signed-off-by: liamhuber <[email protected]> * Jump through mypy hoops It doesn't recognize the __set__ for fset methods on the property, so my usual routes for super'ing the setter are failing. This is annoying, but I don't see it being particularly harmful as the method is private. Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Add dev note Signed-off-by: liamhuber <[email protected]> * Remove HasParent An interface class guaranteeing the (Any-typed) attribute is too vague to be super useful, and redundant when it's _only_ used in `Semantic`. Having a `parent` will just be a direct feature of being semantic. Signed-off-by: liamhuber <[email protected]> * Pull out static method Signed-off-by: liamhuber <[email protected]> * Pull cyclicity check up to Semantic Signed-off-by: liamhuber <[email protected]> * De-parent SemanticParent from Semantic Because of the label arg vs kwarg problem, there is still a vestigial label arg in the SemanticParent init signature. Signed-off-by: liamhuber <[email protected]> * Remove redundant type check This is handled in the super class Signed-off-by: liamhuber <[email protected]> * Give Semantic a generic parent type Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Black Signed-off-by: liamhuber <[email protected]> * Ruff sort imports Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Update docstrings Signed-off-by: liamhuber <[email protected]> * Guarantee that semantic parents have a label Signed-off-by: liamhuber <[email protected]> * 🐛 don't assume parents have semantic_path But we can now safely assume they have a label Signed-off-by: liamhuber <[email protected]> * Pull label default up into Semantic This way it is allowed to be a keyword argument everywhere, except for Workflow which makes it positional and adjusts its `super().__init__` call accordingly. Signed-off-by: liamhuber <[email protected]> * Refactor: label validity check Pull it up from semantic into an extensible method on the mixin class Signed-off-by: liamhuber <[email protected]> * Refactor: rename class Signed-off-by: liamhuber <[email protected]> * Add label restrictions To semantic parent based on its child type's semantic delimiter Signed-off-by: liamhuber <[email protected]> * Improve error messages Signed-off-by: liamhuber <[email protected]> * Make SemanticParent a Generic Signed-off-by: liamhuber <[email protected]> * Don't use generic in static method Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Remove HasParent An interface class guaranteeing the (Any-typed) attribute is too vague to be super useful, and redundant when it's _only_ used in `Semantic`. Having a `parent` will just be a direct feature of being semantic. Signed-off-by: liamhuber <[email protected]> * Pull out static method Signed-off-by: liamhuber <[email protected]> * Pull cyclicity check up to Semantic Signed-off-by: liamhuber <[email protected]> * De-parent SemanticParent from Semantic Because of the label arg vs kwarg problem, there is still a vestigial label arg in the SemanticParent init signature. Signed-off-by: liamhuber <[email protected]> * Remove redundant type check This is handled in the super class Signed-off-by: liamhuber <[email protected]> * Give Semantic a generic parent type Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Black Signed-off-by: liamhuber <[email protected]> * Ruff sort imports Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Update docstrings Signed-off-by: liamhuber <[email protected]> * Annotate some extra returns (#548) Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Make the `HasChannel` interface generic on the `Channel` type (#550) * 🐛 hint with [] for type args Signed-off-by: liamhuber <[email protected]> * Make a generic version of HasChannel Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Generic `HasIO` classes to specify data output panel types (#551) * 🐛 hint with [] for type args Signed-off-by: liamhuber <[email protected]> * Make a generic version of HasChannel Signed-off-by: liamhuber <[email protected]> * Make HasIO generic on the output panel Signed-off-by: liamhuber <[email protected]> * Refactor: introduce generic data outputs panel Signed-off-by: liamhuber <[email protected]> * Remove unnecessary concrete class To reduce misdirection. We barely use it in the super-class and never need to hint it. In contrast, I kept `OutputsWithInjection` around exactly because it shows up in type hints everywhere, so the shorthand version is nice to have. Signed-off-by: liamhuber <[email protected]> * Fix type hints and unused imports Signed-off-by: liamhuber <[email protected]> * More return hints (#552) * Fix returned type of __dir__ Conventionally it returns a list, not a set, of strings Signed-off-by: liamhuber <[email protected]> * Add hints to io Signed-off-by: liamhuber <[email protected]> * Adjust run_finally signature Signed-off-by: liamhuber <[email protected]> * Hint user data Signed-off-by: liamhuber <[email protected]> * Hint Workflow.automate_execution Signed-off-by: liamhuber <[email protected]> * Provide a type-compliant default It never actually matters with the current logic, because of all the checks if parent is None and the fact that it is otherwise hinted to be at least a `Composite`, but it shuts mypy up and it does zero harm. Signed-off-by: liamhuber <[email protected]> * black Signed-off-by: liamhuber <[email protected]> * `mypy` storage (#553) * Add return hints Signed-off-by: liamhuber <[email protected]> * End clause with else Signed-off-by: liamhuber <[email protected]> * Explicitly raise an error After narrowing our search to files, actually throw an error right away if you never found one to load. Signed-off-by: liamhuber <[email protected]> * Resolve method extension complaints Signed-off-by: liamhuber <[email protected]> * `mypy` signature compliance (#554) * Extend runnable signatures Signed-off-by: liamhuber <[email protected]> * Align Workflow.run with superclass signature Signed-off-by: liamhuber <[email protected]> * Relax FromManyInputs._on_run constraint It was too strict for the DataFrame subclass, so just keep the superclass reference instead of narrowing the constraints. Signed-off-by: liamhuber <[email protected]> * black Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * `mypy` draw (#555) * Write 3-tuple explicitly Signed-off-by: liamhuber <[email protected]> * Always hint channels having parents Unlike nodes, the IO and Channel objects it the draw module always wind up having a parent Signed-off-by: liamhuber <[email protected]> * Make draw._Channel generic On the underlying workflow channel type, so the data channel can later access its value. Signed-off-by: liamhuber <[email protected]> * Ruff fix imports Signed-off-by: liamhuber <[email protected]> * Stringify TYPE_CHECKING class uses Oops. Signed-off-by: liamhuber <[email protected]> * Silence ruff The imports are indeed used, but only in string form for the sake of the static type checker. Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Generic value receiver (#556) * 🐛 Re-parent abstract method It belongs with the owners of channels, and these are HasIO, not the IO panels (which are merely dumb containers that give shortcuts to certain functionality) Signed-off-by: liamhuber <[email protected]> * Make DataChannel generic on value_receiver Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Hint attribute Signed-off-by: liamhuber <[email protected]> * Don't reuse variable Signed-off-by: liamhuber <[email protected]> * Only hint available backends Not just any old string Signed-off-by: liamhuber <[email protected]> * Cast docstrings to string Signed-off-by: liamhuber <[email protected]> * Hint NotData class Instead of NOT_DATA instance Signed-off-by: liamhuber <[email protected]> * Just use classmethod It doesn't combine with property Signed-off-by: liamhuber <[email protected]> * Ruff fix imports Signed-off-by: liamhuber <[email protected]> * Remove preview helper method (#557) * Remove preview helper method The potential usage is limited to transform and for-loop modules, and the extra layer of misdirection does not feel worth the very minimal reduction in code duplication Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Relax Node.emitting_channels hint To allow a tuple of variable length Signed-off-by: liamhuber <[email protected]> * Account for __doc__ possibly being None Signed-off-by: liamhuber <[email protected]> * Be more specific in return hint Signed-off-by: liamhuber <[email protected]> * Change return on Composite.remove_child (#558) * Change return on Composite.remove_child To match return in parent class. Disconnections were only ever used in the test case, and users are always free to disconnect and _then_ remove if they want to capture the broken connections explicitly. Signed-off-by: liamhuber <[email protected]> * Remove unused import Signed-off-by: liamhuber <[email protected]> * Fix docstring types Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * IO maps (#559) * Refactor Workflow map setter Signed-off-by: liamhuber <[email protected]> * Remove return hint The method is in-place Signed-off-by: liamhuber <[email protected]> * Move the None check around Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Reverse instance check Signed-off-by: liamhuber <[email protected]> * Return both nodes on replacement (#560) * Return both nodes on replacement Instead of only returning the replaced node. Signed-off-by: liamhuber <[email protected]> * 🐛 only use new variable Missed a spot. Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * Hint graph creator Incompletely for the creator, but I'm having trouble getting mypy happy with hinting args and kwargs here. Signed-off-by: liamhuber <[email protected]> * Don't reuse variable Locally mypy doesn't care about this, but somehow on the CI it whines, even though the mypy version is allegedly the same. Signed-off-by: liamhuber <[email protected]> * Don't reuse variable here either Signed-off-by: liamhuber <[email protected]> * `mypy` for_loop (#561) * Make class "property" a plain method Signed-off-by: liamhuber <[email protected]> * Refactor to non-None classvar Signed-off-by: liamhuber <[email protected]> * Explicitly cast to tuple For the sake of the name generator Signed-off-by: liamhuber <[email protected]> * Silence mypy It is upset about the hinting `list[hint]`, because `hint` is variable. We would be able to verify that it is a type at static analysis time, but since it comes from the body node class -- which is unknown until runtime -- it is impossible to say _which_ type. Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> * `mypy` finishing touches (#562) * Make class "property" a plain method Signed-off-by: liamhuber <[email protected]> * Refactor to non-None classvar Signed-off-by: liamhuber <[email protected]> * Explicitly cast to tuple For the sake of the name generator Signed-off-by: liamhuber <[email protected]> * Silence mypy It is upset about the hinting `list[hint]`, because `hint` is variable. We would be able to verify that it is a type at static analysis time, but since it comes from the body node class -- which is unknown until runtime -- it is impossible to say _which_ type. Signed-off-by: liamhuber <[email protected]> * Uniformly give and ignore classfactory hints At a minimum, getting mypy to parse these correctly requires more rigorous hinting in pyiron_snippets.factory. But actually, since the classfactory allows the parent class to be specified with _multiple bases_, I'm not even 100% sure we'd ever be able to get a single type variable that could do the trick universally. In any case, for now kick the can don't the road and always hint what you know is true, then tell mypy to not worry about it. Signed-off-by: liamhuber <[email protected]> * Add some hints to preview Albeit pretty relaxed ones Signed-off-by: liamhuber <[email protected]> * Add a return hint to Runnable.__init__ To get mypy to parse the body of the function Signed-off-by: liamhuber <[email protected]> * Break loop into a method Mypy didn't like parsing the zip variable when it could be inputs or outputs (even though both inherit from the relevant DataIO in this case), but using a separate method is functionally equivalent and mypy can get a better grasp of the type values. Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> --------- Signed-off-by: liamhuber <[email protected]> Co-authored-by: Sebastian Eibl <[email protected]>
Little tweaks to the IO maps for Workflows