Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples / alternative docs using Python 3.12 PEP 695 #81

Open
SimonHeybrock opened this issue Dec 5, 2023 · 2 comments
Open

Add examples / alternative docs using Python 3.12 PEP 695 #81

SimonHeybrock opened this issue Dec 5, 2023 · 2 comments

Comments

@SimonHeybrock
Copy link
Member

Example:

type mylist[T] = list[T]
type mydict[V] = dict[str, V]

import sciline as sl

def make_int_list() -> mylist[int]:
    return [1, 2, 3]

def make_str_list() -> mylist[str]:
    return ['a', 'b', 'c']

def f[T](x: mylist[T]) -> mydict[T]:
    return {f'{x}': x}

pl = sl.Pipeline([f, make_int_list, make_str_list])
pl.get(mydict[int]).compute()

This is much cleaner than the sciline.Scope helper and the use of NewType.

Note that mypy might still not support this (fully).

@YooSunYoung
Copy link
Member

Looks really neat!
Does it imply that we can only use python 3.12 for docs build?

@SimonHeybrock
Copy link
Member Author

Does it imply that we can only use python 3.12 for docs build?

Yes, I think so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

2 participants