Skip to content

Remove supertype in Scope? #202

Description

@jl-wynen

Can we remove the supertype in scope definitions? It does not seem to serve any purpose any more. Or am I missing something?

For example, when I remove SUPER from Scope:

class Scope(Generic[PARAM]):
    def __init_subclass__(cls, **kwargs: Any) -> None:
        return super().__init_subclass__(**kwargs)

    def __new__(cls, x: T) -> T:  # type: ignore[misc]
        return x

this runs fine and passes type checks:

from typing import NewType, TypeVar
import sciline as sl

A = NewType('A', int)
B = NewType('B', int)
T = TypeVar('T', A, B)

class X(sl.Scope[T], int): ...
class Y(sl.Scope[T], int): ...

def foo(x: X[T]) -> Y[T]:
    return Y[T](x + 1)

pl = sl.Pipeline([foo], params={X[A]: 3, X[B]: 4})
print(pl.visualize())
print(pl.compute(X[A]))

Is the supertype simply a leftover from an earlier version of Sciline or do we still need it?

Of course, doping this would require a lot of changes in downstream code. But I think the reduced duplication would be worth it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions