Page MenuHomeSoftware Heritage

typing: minimal changes to make a no-op mypy run pass
ClosedPublic

Authored by zack on Fri, Sep 20, 11:23 AM.

Diff Detail

Repository
rDMOD Data Model
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

zack created this revision.Fri, Sep 20, 11:23 AM
zack updated this revision to Diff 6770.Fri, Sep 20, 11:28 AM
  • mypy.ini: remove left-over sample section
vlorentz added inline comments.
swh/model/hashutil.py
74

Dict[str, Callable[[], hashutil.hash]]

swh/model/identifiers.py
641–649

Declare the NamedTuple in another class, and name it eg. _PersistentId.

Or just declare attributes using the attr lib.

swh/model/merkle.py
113

we may want to make this an enum

zack updated this revision to Diff 6773.Fri, Sep 20, 12:14 PM
zack marked 3 inline comments as done.
  • mypy: ignore django-stubs, needed only by hypothesis
  • identifiers.py: do not inherit from on-the-fly namedtuple
swh/model/hashutil.py
74

There doesn't seem to be a proper public abstract type for the hashes returned by hashlib: they're _hashlib.HASH and I'd rather not use a private module in a type definition.

swh/model/merkle.py
113

agreed, but not in this diff, right?

I've added an inline TODO now though.

vlorentz accepted this revision.Fri, Sep 20, 1:32 PM
This revision is now accepted and ready to land.Fri, Sep 20, 1:32 PM