Skip to content

Update to use newer type parameters #311

Description

@marcuscollins

When working on bringing protpardelle into SW, I ran into the following type of listing error:

UP047 Generic function `require_boltz` should use type parameters
  --> src/sampleworks/utils/imports.py:57:5
   |
56 | @overload
57 | def require_boltz(message: F) -> F: ...
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
58 | @overload
59 | def require_boltz(message: str | None = None) -> Callable[[F], F]: ...
   |
help: Use type parameters

F in this case is a TypeVar: F = TypeVar("F", bound=Callable[..., Any]). The newer way to do this is, I think:

def require_boltz[F: Callable[..., Any]](message: F) -> F

There are 11 such errors in imports.py, and presumably we can use this elsewhere as well. We should check that it is actually compatible with our version of Python.

For now I've just added # ruff: noqa: UP047 to that file.

Metadata

Metadata

Assignees

Labels

P1engineeringTask that is best suited to software engineers, not research scientists

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions