Skip to content

Narrow Cell as TypeAlias for some interface? #605

@DanielYang59

Description

@DanielYang59

Currently Cell is defined to be a tuple of 3 or 4: https://github.com/spglib/spglib/blob/develop/python/spglib/spglib.py#L70-L72

And some API would only give tuple of 3: https://github.com/spglib/spglib/blob/develop/python/spglib/spglib.py#L1425-L1428

And mypy would complain for such cases unless I explicitly check the length, I wouldn't say this is wrong because Cell is broader but narrowing it would be more convenient:

lattice, scaled_positions, numbers = spglib.refine_cell(self._cell, self._symprec, self._angle_tol)

>>> error: Too many values to unpack (3 expected, 4 provided)  [misc]

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