Open PicoCentauri opened 3 years ago
From which version of Python onwards is type hinting supported?
How does this fit into the current roadmap/NEP29 ?
cc @IAlibay
3.5, I think 3.7 is when it got a lot better, and numpy.typing
is only supported from 1.20.0 onwards, which is IIRC 3.7+.
So 2.1.0 is going to be 3.7+ but according to NEP29, we don't drop 1.19 until June 2022 (see: https://numpy.org/neps/nep-0029-deprecation_policy.html#drop-schedule).
I would be in favour of waiting until we can fully use numpy's typing functionality (rather than implementing something now and then redoing it later). That being said, if bits of the API can start to be typed without hurting other bits then that's fine (as long as we keep detailed notes of the process and what needs doing!)
Is this something we can work on now now? I think this would be a great feature for ease of use and avoiding strange errors.
Is this something we can work on now now? I think this would be a great feature for ease of use and avoiding strange errors.
I believe this is at least part of a propose GSoC project. Due to clashes regarding this it would be best to avoid at this point in time.
Hi, this is my first time with open source, I want to do Type hinting in this project. An example of my work is below. Example:- python code for addition function ->
def add_numbers(num1, num2): return num1 + num2 print(add_numbers(3, 5)) # 8
->type hinted code >
def add_number( int : num1 , int : num2) -> int : return num1+num2; print(add_numbers(3, 5)) # 8
Please tell me how can I start with the project
@1krishnasharma for questions about projects and Outreachy/GSOC please ask on the developer mailing list. Examples of how you would apply type hinting to MDAnalysis would go in your proposal/application.
Is your feature request related to a problem?
With the first version of the CLI released, we now would like to support more Analysis classes. This is especially limited to classes taking lists as parameters as the InterRDF_s
https://github.com/MDAnalysis/mdanalysis/blob/735abb8c76d71e1dc8197d73ee6f5d1845634914/package/MDAnalysis/analysis/rdf.py#L429-L447
where
ags
is a list ofAtomGroups
. For building the CLI we have to know the variable type. For example, what is the type of the list elements. The current implementation does not allow this. To overcome this issue we could introduce type hints as they were discussed in issues previously.Describe the solution you'd like
Adding type hints to the Analysis classes. Type hints can be easily extracted using the
typing
moduleDescribe alternatives you've considered
Be more precise in the docstring about parameter types. Similar to type hints but only (or maybe additionally) in the docstring.