cardano-python icon indicating copy to clipboard operation
cardano-python copied to clipboard

Python2 or 3 or both ?

Open anooprh opened this issue 4 years ago • 4 comments

My only ask is to be compatible with python3. I see you had used python 2 style class declarations

class WalletService(object):
    ....

My order of preference would be

  1. Python3 code but be usable with both python2 and python3
  2. Python3 code but be usable with only python3

anooprh avatar Mar 11 '21 10:03 anooprh

Does it cause any problems in Python3?

emesik avatar Mar 11 '21 12:03 emesik

Does it cause any problems in Python3?

It works. There is no issue with that at all.

But when looking at the code to understand what it is doing, not seeing the type annotations is kind of confusing. Or maybe thats just me been using python3 with type annotations for several years now.

anooprh avatar Mar 11 '21 15:03 anooprh

Well, I've never used them personally and always described types in the docstring. However, if annotations turn out nicely in auto-generated docs, we might consider that solution.

I'm rather not planning to make the code compatible with Py2, if that matters. Although I'm not considering that decision final.

For doc generation I'd like to use Sphinx

emesik avatar Mar 12 '21 21:03 emesik

Since python 2 is no longer supported, I would say it's safe to drop python 2 and use just python from e.g. 3.6.

Type annotations are very useful IMHO (linting, refactoring, code navigation). We use them in our IOHK python projects, like https://github.com/input-output-hk/cardano-node-tests and https://github.com/input-output-hk/cardano-clusterlib-py You can see how it looks like in sphinx docs in https://cardano-clusterlib-py.readthedocs.io/en/latest/cardano_clusterlib.html#module-cardano_clusterlib.clusterlib

off topic: Also tools for automatic code checking and formatting make it easier to contribute, find errors as well as clean code from legacy stuff, like constructs used in old python versions (this class Something(object), etc.). E.g. pre-commit with checks like black, flake8, pyupgrade, ... - https://github.com/input-output-hk/cardano-clusterlib-py/blob/master/.pre-commit-config.yaml

mkoura avatar Apr 08 '21 13:04 mkoura