Open marcharper opened 7 years ago
I am interested in working on the issue.
@souravsingh Great! It's a huge undertaking so feel free to tackle it in chunks, maybe file by file, and open multiple PRs if you'd like. And don't feel any pressure to do it all.
A few notes:
NewType
for things like axelrod.Actions.C
(rather than say str
) and then import that type as needed. This is so if we decide to e.g. change the actions to 0 and 1 rather than 'C'
and 'D'
then we'll get the rest of the types for free. E.g. the history would be a list of whatever type the action is, and List[T]
where T
is the type variable for action is better than List[str]
as the type for history.We're in uncharted territory here so if you are not sure how to annotate something, either leave it alone or open an issue and we'll discuss it.
@meatballs @drvinceknight Have you seen PEP 526? It's Python 3.6 only and relevant to this issue. Unfortunately Python 3.7 won't be released for 18 months...
Just read it :)
@drvinceknight we should look into running a type checker (with travis?) once we have a some annotations in.
Yeah: great idea! Do you know of a type checker for Python? A quick google has lead me to give up as the wifi is a bit slow in my hotel right now...
@drvinceknight @marcharper We can make use of mypy for type checks. Guido likes the tool himself.
mypy
is probably a good choice, assuming we can make it work with travis -- it's been around for a while (and is the only type checker I've used before).
There is pytest plugin for mypy here- https://github.com/dbader/pytest-mypy We can utilise it
Here's a patch that another project used to incorporate mypy
.
There is another package for type checking called Traits- https://github.com/enthought/traits
Here's a patch that another project used to incorporate mypy.
Looks simple enough to me.
There is another package for type checking called Traits- https://github.com/enthought/traits
@souravsingh do you think there's anything that Traits adds over mypy?
@drvinceknight All I can think of is it supports Type Validation, Notification to other programs if the type of a varibale is changed. I haven't really used traits a lot.
Thanks @juliahou8 and @souravsingh for getting the ball rolling on this issue!
@marcharper I would like to work on this issue. Maybe a stupid question, but do you want to add type hints for the whole project, strategies and tests, etc?
Whenever possible other than tests IMO.
Hey.
I have heard that this issue isvery easy to begin with and am really beginner so i would like to start with it. Someone suggested me to take this issue and add type hints on these files : finite_state_machines.py, hmm.py, human.py
I will start from (really) Zero as i dont even know what is PRs and Type Hints , so i hope to have finished all these by Friday ...
So may i take this issue for this files ???
Thank you very much Marios Zoulias
@MariosZoulias I would suggest you to work on any one of the file for the PR. For contributing see here- http://axelrod.readthedocs.io/en/latest/tutorials/contributing/strategy/instructions.html For Type hinting, Read this- https://docs.python.org/3/library/typing.html
Let us know if you need any more help.
Ok then i would like to work on this issue and start with hmm.py I didnt answer fast because i was searching about what is type hinting and more about it... Can you give me some examples of file "before and after" type hinting in order to have a better view??? Thank you Marios Zoulias
@MariosZoulias you can check out any of the merged PRs referencing this issue a few comments above above, and click on Files Changed
.
Thank you very much for your fast aswer. So anyway i have the issue about the hmm.py file ??? (am just beginner and i dont really know the procedure) (of course i read the contributing instructions)
@MariosZoulias Could we take this up in the gitter room? Also, i didn't quite understand your problem.
Yes of course am already there ;)
Here is the list of files in main module done so far-
That's awesome :+1: @souravsingh
Let me know if I have missed something in the main module, I just skimmed through the code.
I will also be making a second list for the type hint progress in strategies module.
I would like to take up match.py
and match_generator.py
, if that's fine.
That's great, thanks @janga1997!
For strategies we have this list(Almost everything is done and finished by @janga1997 )-
[ ] _filters.py
[x] adaptive.py
[x] alternator.py
[x] ann.py
[x] apavlov.py
[x] alternator.py
[x] appeaser.py
[x] averagecopier.py
[x] axelrod_first.py
[x] axelrod_second.py
[x] backstabber.py
[x] better_and_better.py
[x] calculator.py
[x] cooperator.py
[x] cycler.py
[x] darwin.py
[ ] dbs.py
[x] doubler.py
[x] defector.py
[x] finite_state_machines.py
[x] forgiver.py
[x] gambler.py
[x] geller.py
[x] gobymajority.py
[x] gradualkiller.py
[x] grudger.py
[x] grumpy.py
[x] handshake.py
[x] hmm.py
[x] human.py
[x] hunter.py
[x] inverse.py
[x] lookerup.py
[x] mathematicalconstants.py
[x] memoryone.py
[x] memorytwo.py
[x] meta.py
[x] mindcontrol.py
[x] mindreader.py
[x] mutual.py
[x] negation.py
[x] prober.py
[x] punisher.py
[x] qlearner.py
[x] rand.py
[x] resurrection.py
[x] retaliate.py
[x] selfesteem.py
[x] sequence_player.py
[x] stalker.py
[x] titfortat.py
[x] very_bad.py
[x] worse_and_worse.py
@souravsingh I'm looking to complete the whole thing. I'm taking up graph.py
for now.
@eshansingh Awesome. Go for it
are all the files completed here?
They pretty much are, if there's a file that is said to be complete here but it doesn't look like it is let us know :)
Now that we're Python 3.5+ exclusive, it's time for type hints!
Note to contributors: please run mypy on any newly annotated files. After installing with
pip install mypy
, please run:mypy --ignore-missing-imports --follow-imports skip axelrod/<file.py>
for whichever files you annotate. You should receive no errors. We'll get this added to the automated checks soon. Thanks!
Finally, note that we're officially supporting Python 3.5 and 3.6, so please don't use any of the newer typing features in Python 3.6 yet.