scylla-ccm icon indicating copy to clipboard operation
scylla-ccm copied to clipboard

node,scylla_node,cluster,scylla_cluster: Add type hints for nodes and clusters

Open cezarmoise opened this issue 1 year ago • 4 comments

  • Add type hints for nodes and clusters to help debugging in dtest
  • Fix linting / formatting issues

cezarmoise avatar Sep 12 '24 14:09 cezarmoise

I will do a jenkins run to check for issues

cezarmoise avatar Sep 12 '24 14:09 cezarmoise

I would recommend add some linter that can identify those, and configure it specific to check those files in CI.

I think ruff might be use to force adding type notation

or mypy --disallow-untyped-functions

fruch avatar Sep 12 '24 15:09 fruch

I would recommend add some linter that can identify those, and configure it specific to check those files in CI.

I think ruff might be use to force adding type notation

or mypy --disallow-untyped-functions

Those tools check all function parameters. For example, with ruff I get that there are about 3000 untyped parameters or function returns. I just added hints where nodes and clusters were involved, so it's easier for the editor to navigate trough their methods.

cezarmoise avatar Sep 13 '24 09:09 cezarmoise

I will do a jenkins run to check for issues

https://jenkins.scylladb.com/view/master/job/scylla-master/job/byo/job/dtest-byo/564/ Ran without issues

cezarmoise avatar Sep 13 '24 14:09 cezarmoise

https://github.com/scylladb/scylla-ccm/commit/df0a17a748a30e5fbd478290a734159b42f42535 rebased to solve conflicts

cezarmoise avatar Sep 25 '24 08:09 cezarmoise

My only issue is that typing.* are deprecated since 3.9, because now you can use inbuilt types for typing instead, e.g. test: list[str] = []

See https://docs.python.org/3/library/typing.html#aliases-to-types-in-collections

Not sure whaat is our minimal working version, but 3.9 seems old & stable enough to do it the new way. @fruch WDYT?

The minimum is 3.8, we need to support the same versions as the python-driver does, cause ccm is used in it's testing

The typing.* isn't yet deprecated AFAIK, linters are suggesting not to use it.

fruch avatar Sep 25 '24 18:09 fruch