zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

Inconsistent overridden method

Open DimitriPapadopoulos opened this issue 1 year ago • 3 comments

Zarr version

v3

Installation

sources

Description

These methods of abstract base class Store are non-async:

Child classes LocalStore, LoggingStore, RemoteStore, MemoryStore, ZipStore override these functions as async. Take the example of ZipStore:

Is that on purpose? I think async is part of the method signature and should be added to the base class.

DimitriPapadopoulos avatar Oct 15 '24 16:10 DimitriPapadopoulos

This is intentional but I don't remember all the details. It has to do with how Python does abstract methods for async generators IIRC. If there is a better solution, I'd be happy to see one come forward though.

jhamman avatar Oct 15 '24 16:10 jhamman

I'm afraid I don't have much experience with async methods, so I cannot help much.

It's just that:

  • I've seen abstract base classes add async to the method definition - and perhaps add an empty yield so that linters are happy. See for example https://github.com/microsoft/pyright/discussions/4741.
  • Some linters complain about the current situation: https://app.deepsource.com/gh/DimitriPapadopoulos/zarr-python/issue/PYL-W0236/occurrences

I could start a PR where I try to add async to the abstract base class methods, so we can see what happens. How does it sound?

DimitriPapadopoulos avatar Oct 15 '24 16:10 DimitriPapadopoulos

Go for it @DimitriPapadopoulos!

jhamman avatar Oct 15 '24 16:10 jhamman