-
Notifications
You must be signed in to change notification settings - Fork 3
mypy
compliance
#533
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
mypy
compliance
#533
Conversation
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
typing._UnionGenericAlias definitively _does_ exist. Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Based on @jan-janssen's jobs for other pyiron repos Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Windows tests failed, but EDIT: Yep. Better now. |
* Leverage generics for connection partners Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Break apart connection error message So we only reference type hints when they're there Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Hint connections type more specifically Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Hint disconnect more specifically Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Use Self in disconnection hints Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Use Self to hint value_receiver Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Fix typing in channel tests Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 🐛 Return the message Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Fix typing in figuring out who is I/O Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Match Accumulating input signal call to parent Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
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 |
Pull Request Test Coverage Report for Build 12839449964Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
I currently only point |
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 <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope I got the idea of the channels, right.
I favor smaller piece to review. I do not think I will be able to do a review of the final branch. But I can have a look at the smaller pieces if you want. |
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 <liamhuber@greyhavensolutions.com>
Yes, that's fair. Ok, so then we'll modify slightly: I'll ping you for review on each of the smaller stacked PRs instead and you're free to review them (or not) at your leisure. I'll leave them open for as long as I can, but if I'm worried about merge conflicts before you have a chance to get to it, I'll still just merge them down. You can nonetheless provide feedback on them post-merge, and we can simply slap on patching branches when it's convenient, ala #535. |
* Refactor: rename Move from "partner" language to "conjugate" language Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Explicitly decompose conjugate behaviour Into flavor and IO components Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Tidying Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Narrow hint on connection copying Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Refactor: rename Move from "partner" language to "conjugate" language Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Explicitly decompose conjugate behaviour Into flavor and IO components Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Tidying Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Narrow hint on connection copying Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Apply hints to IO panels Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Narrow type Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Don't reuse variable Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Ruff: sort imports Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 🐛 fix type hint Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add more hints Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
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 <liamhuber@greyhavensolutions.com>
* Hint init properties Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Hint local function Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add stricter return and hint Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 🐛 Hint tuple[] not () Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Black Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Don't overload typed variable Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add (and more specific) return hint(s) To the one function missing one Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add module docstring Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Catch module spec failures Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Black Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Ruff import sort Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Refactor connection validity
* Initialize _label to a string Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Hint the delimiter Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Make SemanticParent a Generic Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Update comment Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Use generic type Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Don't use generic in static method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add dev note Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Make SemanticParent a Generic Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Don't use generic in static method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Pull out static method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Pull cyclicity check up to Semantic Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Remove redundant type check This is handled in the super class Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Give Semantic a generic parent type Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Black Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Ruff sort imports Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Update docstrings Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Initialize _label to a string Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Hint the delimiter Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Make SemanticParent a Generic Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Update comment Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Use generic type Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Don't use generic in static method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add dev note Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Pull out static method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Pull cyclicity check up to Semantic Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Remove redundant type check This is handled in the super class Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Give Semantic a generic parent type Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Black Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Ruff sort imports Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Update docstrings Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Guarantee that semantic parents have a label Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 🐛 don't assume parents have semantic_path But we can now safely assume they have a label Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Refactor: label validity check Pull it up from semantic into an extensible method on the mixin class Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Refactor: rename class Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add label restrictions To semantic parent based on its child type's semantic delimiter Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Improve error messages Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Make SemanticParent a Generic Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Don't use generic in static method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Pull out static method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Pull cyclicity check up to Semantic Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Remove redundant type check This is handled in the super class Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Give Semantic a generic parent type Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Black Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Ruff sort imports Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Update docstrings Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Annotate some extra returns (#548) Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* 🐛 hint with [] for type args Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Make a generic version of HasChannel Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* 🐛 hint with [] for type args Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Make a generic version of HasChannel Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Make HasIO generic on the output panel Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Refactor: introduce generic data outputs panel Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Fix type hints and unused imports Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * More return hints (#552) * Fix returned type of __dir__ Conventionally it returns a list, not a set, of strings Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add hints to io Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Adjust run_finally signature Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Hint user data Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Hint Workflow.automate_execution Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * black Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * `mypy` storage (#553) * Add return hints Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * End clause with else Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Resolve method extension complaints Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * `mypy` signature compliance (#554) * Extend runnable signatures Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Align Workflow.run with superclass signature Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * black Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Write 3-tuple explicitly Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Make draw._Channel generic On the underlying workflow channel type, so the data channel can later access its value. Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Ruff fix imports Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Stringify TYPE_CHECKING class uses Oops. Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Silence ruff The imports are indeed used, but only in string form for the sake of the static type checker. Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* 🐛 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 <liamhuber@greyhavensolutions.com> * Make DataChannel generic on value_receiver Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Not just any old string Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Instead of NOT_DATA instance Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
It doesn't combine with property Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* 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 <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
To allow a tuple of variable length Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* 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 <liamhuber@greyhavensolutions.com> * Remove unused import Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Fix docstring types Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Refactor Workflow map setter Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Remove return hint The method is in-place Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Move the None check around Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Return both nodes on replacement Instead of only returning the replaced node. Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 🐛 only use new variable Missed a spot. Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
Incompletely for the creator, but I'm having trouble getting mypy happy with hinting args and kwargs here. Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
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 <liamhuber@greyhavensolutions.com>
Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Make class "property" a plain method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Refactor to non-None classvar Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Explicitly cast to tuple For the sake of the name generator Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
* Make class "property" a plain method Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Refactor to non-None classvar Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Explicitly cast to tuple For the sake of the name generator Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> * Add some hints to preview Albeit pretty relaxed ones Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * Add a return hint to Runnable.__init__ To get mypy to parse the body of the function Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com> * 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 <liamhuber@greyhavensolutions.com> --------- Signed-off-by: liamhuber <liamhuber@greyhavensolutions.com>
At the last meeting of December, @niklassiemer indicated he was fine learning whatever typing stuff was necessary in the event he takes over maintenance, so this PR is intended to close #514.
My current plan is to take any low-hanging fruit (e.g. hinting
typing.Callable
instead ofcallable
) and just commit it directly here, but to break larger changes into stacked PRs so it's easier to view the diff and see intentions. I started using a file-based approach and have a branch for getting thechannels
sub-module compliant, but for things in themixins
it may make more sense to group the PRs so they touch multiple files, but updating a single root class.@niklassiemer, you may want to keep an eye on this series of PRs just to get a rough sense of what was involved in this transition.
@XzzX, I'll ping you for review on this root branch when I feel it's done, but I'll freely merge the feature/file branches into it without delay. Nonetheless, feel free to also keep an eye on the whole series of PRs and interject whenever you have insight, and/or just stack fixes you want right on top of here.
EDIT: as long as it's in draft state, I'm not going to sweat about ruff and black failures. Definitely before merging, and I'll try to patch them up when I get a chance, but I am going to prioritize avoiding merge conflicts with any stacked branches over keeping the formatters permanently happy.
Progress tracker:
mypy
complaintsmypy
channels #534) 148mypy
channels redux #536 and Apply hints to IO panels #537) 126mypy
run #541) 119mypy
topology and find #542) 114mypy
semantics #538) 106HasChannel
interface generic on theChannel
type #550) 99HasIO
classes to specify data output panel types #551) 84mypy
storage #553) 63mypy
signature compliance #554) 56mypy
draw #555) 52mypy
for_loop #561) 8mypy
finishing touches #562) 0