-
Notifications
You must be signed in to change notification settings - Fork 262
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
Add type hints for ecosystem #832
Add type hints for ecosystem #832
Conversation
Hi @janga1997, thanks for working on this.
The type is |
@drvinceknight In this case, can we go along with |
Although ideally the type of
So that might need something... |
@drvinceknight I kinda understand what the problem is, but I don't know the solution to it. |
I'm not entirely sure what the solution is either (@marcharper, @Nikoleta-v3 ?).
I don't see why not. |
@drvinceknight I facing some trouble with the type of results? Would you mind? |
Yup, you'll need to do that. :) |
@drvinceknight Is it okay for a merge now? |
It looks good to me. We have a two core reviewer policy on all PRs so someone else will be around to make sure I haven't missed anything (or if they see the way to get around the |
Is it always a results set from a file? |
@marcharper not sure. I faced this issue when adding type hints for derived classes of |
According to the docs it looks like a subclass will type check as valid if a parent class is expected. Let's test for the parent type if multiple possible derived types are possible. |
@marcharper just to be sure, I use |
Unless you know for sure that something more specific is appropriate. Also please try to run mypy on the files you annotate: You may get some errors until #837 is merged (you can rebase if you know how to do that). |
Type checker says:
Let us know if you need help (and feel free to join the gitter chat to ask questions). |
@marcharper The remaining errors seem to be from this line |
Try a float -- there's no reason to force an integer here -- and see if it works. Otherwise let's use |
@drvinceknight There is still one error remaining, for the line |
It looks like a Callable type will do the trick:
|
@drvinceknight Yeah, but didn't we decide upon FunctionType? Why are we doing |
I think my original advice on the use of https://docs.python.org/3/library/typing.html#typing.Callable An in fact I think it should actually be:
which indicates that it's a callable that takes a |
Apologies, it should be:
|
This looks fine to me now. 👍 |
Fixes part of #808
I have no idea what type of a variable
fitness
is. Could someone help out?