-
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
Use inspect in order to get type hint metadata #570
base: main
Are you sure you want to change the base?
Conversation
I don't think I'll have the time to support and dig deep on this until the end of next week, but to try to help a little at first glance: the error looks as though the code want's a tuple of hints (even if they're None) but the new routine provides an empty tuple. Since you're replacing one standard library call for a different one (plus some manipulation), I guess that for now it's just a matter of getting the new call + manipulation to conforming to the return type of the old one -- i.e. I don't expect complications from
No, what you're doing here is the transformation. Subclasses of classes like |
That's fine. I was anyway going to work on it myself. I just thought you might know where the problem comes from. Maybe I make it a bit more specific what I wanted to say in my post above: The following snippet delivers the same results for a given function sig = inspect.signature(f)
type_dict = {
key: value.annotation for key, value in sig.parameters.items()
}
type_dict = type_dict | {"return": sig.return_annotation}
type_dict = {
k: v for k, v in type_dict.items() if v != inspect.Parameter.empty
} The weird thing is, inside @as_function_node("started_at", "ended_at", "was_empty")
def ChangeDirectory(
path: str | Path,
delete_start: bool = False,
) -> tuple[str, str, bool]: and Anyway I was thinking about working on it myself, so if nothing comes to your mind, just leave it like this. |
Thanks to this post I found out the reason - apparently |
…ace None by NoneType
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 12947532852Warning: 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 was trying to get full type hints by using
inspect
instead ofget_type_hints
.Well, this being said I'm painfully aware of the fact that the tests fail, but I don't really know why XD The problem comes from the fact that somehow
type_dict["return"]
turns the return type into a string, so for example instead oftuple[float, float, float]
you get"tuple[float, float, float]"
, even though if I copy and paste the code snippet I can get the correct type. Is there any transformation that takes place beforepreview_io
?