Skip to content
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

Merged
merged 45 commits into from
Jan 18, 2025
Merged

mypy compliance #533

merged 45 commits into from
Jan 18, 2025

Conversation

liamhuber
Copy link
Member

@liamhuber liamhuber commented Jan 8, 2025

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 of callable) 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 the channels sub-module compliant, but for things in the mixins 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 complaints

typing._UnionGenericAlias definitively _does_ exist.

Signed-off-by: liamhuber <[email protected]>
Based on @jan-janssen's jobs for other pyiron repos

Signed-off-by: liamhuber <[email protected]>
Copy link

github-actions bot commented Jan 8, 2025

Binder 👈 Launch a binder notebook on branch pyiron/pyiron_workflow/mypy

@liamhuber
Copy link
Member Author

liamhuber commented Jan 8, 2025

Windows tests failed, but CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/conda-forge/noarch/repodata.json>, so hopefully it is just a hiccup.

EDIT: Yep. Better now.

* 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]>
Copy link

codacy-production bot commented Jan 8, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.09% (target: -1.00%) 95.66%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (53a5c14) 3356 3070 91.48%
Head commit (e36409b) 3425 (+69) 3130 (+60) 91.39% (-0.09%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#533) 415 397 95.66%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@coveralls
Copy link

coveralls commented Jan 8, 2025

Pull Request Test Coverage Report for Build 12839449964

Warning: 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

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 200 unchanged lines in 23 files lost coverage.
  • Overall coverage decreased (-0.09%) to 91.387%

Files with Coverage Reduction New Missed Lines %
nodes/function.py 1 98.41%
type_hinting.py 1 97.78%
nodes/transform.py 2 98.24%
mixin/single_output.py 2 97.53%
nodes/for_loop.py 2 98.21%
mixin/has_interface_mixins.py 3 90.0%
find.py 3 90.32%
storage.py 4 95.37%
topology.py 5 88.61%
mixin/injection.py 6 95.28%
Totals Coverage Status
Change from base Build 12778163625: -0.09%
Covered Lines: 3130
Relevant Lines: 3425

💛 - Coveralls

@liamhuber
Copy link
Member Author

I currently only point mypy at the main module; I'd like to make the tests compliant as well, but that can be done at a later time in a separate PR.

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]>
Signed-off-by: liamhuber <[email protected]>
Copy link
Contributor

@XzzX XzzX left a 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.

pyiron_workflow/channels.py Outdated Show resolved Hide resolved
pyiron_workflow/channels.py Outdated Show resolved Hide resolved
@XzzX
Copy link
Contributor

XzzX commented Jan 9, 2025

@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.

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 <[email protected]>
@liamhuber
Copy link
Member Author

@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.

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.

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 <[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]>
* 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]>
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]>
liamhuber and others added 4 commits January 10, 2025 16:06
* 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]>
* 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]>
* 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]>
* 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]>
* 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]>
* 🐛 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]>
* 🐛 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]>
* 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]>
* 🐛 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]>
Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Not just any old string

Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Instead of NOT_DATA instance

Signed-off-by: liamhuber <[email protected]>
It doesn't combine with property

Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
* 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]>
To allow a tuple of variable length

Signed-off-by: liamhuber <[email protected]>
* 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]>
* 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]>
Signed-off-by: liamhuber <[email protected]>
* 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]>
Incompletely for the creator, but I'm having trouble getting mypy happy with hinting args and kwargs here.

Signed-off-by: liamhuber <[email protected]>
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]>
* 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]>
* 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]>
@liamhuber liamhuber marked this pull request as ready for review January 18, 2025 01:15
@liamhuber liamhuber merged commit e316d6e into main Jan 18, 2025
19 of 20 checks passed
@liamhuber liamhuber deleted the mypy branch January 18, 2025 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include a static type checker?
3 participants