orchest icon indicating copy to clipboard operation
orchest copied to clipboard

Add types to Python code

Open ricklamers opened this issue 4 years ago • 5 comments

Describe the solution you'd like
Add types to Python codebase

What does your solution aim to solve?
Make it more explicit what arguments functions take and therefore make it easier to extend consume or refactor code.

ricklamers avatar Aug 30 '21 20:08 ricklamers

Whilst working on this it is good to keep in mind the changes that are introduced in Python3.9, see Pep 585 (deprecating things like typing.Iterable).

For the time being we will stay on Python3.8 because of the base images we use for the orchest-api, auth-server, orchest-webserver and update-server: tiangolo/meinheld-gunicorn-flask, which does not yet have a Python3.9 version available.

An example module where we already use type hints is analytics.py.

yannickperrenet avatar Aug 31 '21 07:08 yannickperrenet

i still don't understand how you want this to be resolved

balotofi avatar May 28 '22 20:05 balotofi

Hi @balotofi! The idea is to extend gradual typing like this:

https://github.com/orchest/orchest/blob/b39ded5eca8e9ededf5e246de11e0c2581048beb/services/orchest-webserver/app/app/analytics.py#L131-L133

To the rest of the codebase.

One can start module by module, or package by package, rather than spending a lot of time working on a huge pull request.

astrojuanlu avatar May 29 '22 09:05 astrojuanlu

@astrojuanlu I can help with this. Got a preference which part of the codebase should I focus on first?

Are we still sticking to typing as it was on Python 3.8 or should I use the standards of Python 3.9?

sbarrios93 avatar Aug 23 '22 00:08 sbarrios93

Thanks @sbarrios93! We'll continue the conversation about #1216 on the PR itself.

About the Python version, I opened https://github.com/orchest/orchest/issues/1217.

astrojuanlu avatar Aug 23 '22 06:08 astrojuanlu