nipreps / mriqc

Automated Quality Control and visual reports for Quality Assessment of structural (T1w, T2w) and functional MRI of the brain
http://mriqc.readthedocs.io
Apache License 2.0
299 stars 132 forks source link

Type annotation of config module #1248

Closed oesteban closed 3 months ago

oesteban commented 7 months ago

In general, it would be best practice to annotate, but it is of particular interest to the config module, as it will make the documentation of settings way more transparent and clear.

Any takers?

cc/ @celprov @mckenziephagen @teresamg @ZviBaratz

celprov commented 7 months ago

I'm afraid I don't understand what is needed.

oesteban commented 7 months ago

Here's a gentle explanation about type annotation: https://blog.logrocket.com/understanding-type-annotation-python/.

In practice, this is about adding type hints to each of the configurable variables. For example, instead of:

x = 5.0

you can annotate this and say:

x: float = 5.0

which explicitly says this variable should be a float.

Type annotation also works for functions:

def hello(name):
    print(f'Hi {name}')

becomes:

def hello(name : str) -> None:
    print(f'Hi {name}')

which explicitly tells you the function accepts a string through the argument name and returns a None.

ZviBaratz commented 7 months ago

If it's not too urgent, I wouldn't mind trying to take it on sometime in the next couple of weeks.

oesteban commented 7 months ago

@ZviBaratz - two weeks is excellent timing.

oesteban commented 3 months ago

Done in #1288.