beets icon indicating copy to clipboard operation
beets copied to clipboard

Add typings to the art resizer module

Open Serene-Arc opened this issue 1 year ago • 2 comments

Continuing my effort to type the modules of beets, here's another module typed. Few comments:

  • Pillow's Image module is imported at the top so I could use the typings. There are other duplicate imports in the code; the tests run so it doesn't cause problems there but I don't know why it was done in the first place so worth noting
    • If it's fine, then there are duplicate imports that should be removed
  • @wisp3rwind said that beets considers every path beyond the core to be a string, or whatever needed by external APIs. I have here typed them to be AnyStr which includes both bytes and strings for maximum breadth, but if they are truly strings, then this can be tightened.

Serene-Arc avatar Jan 22 '23 02:01 Serene-Arc

  • Pillow's Image module is imported at the top so I could use the typings. There are other duplicate imports in the code; the tests run so it doesn't cause problems there but I don't know why it was done in the first place so worth noting

    • If it's fine, then there are duplicate imports that should be removed

The purpose of the delayed imports is to only require these libraries if they actually end up being used. See the __init__ methods on the two backend classes. Thus, this should stay as is. For typing, we could maybe hide this behind a https://docs.python.org/3/library/typing.html#typing.TYPE_CHECKING check?

  • @wisp3rwind said that beets considers every path beyond the core to be a string, or whatever needed by external APIs. I have here typed them to be AnyStr which includes both bytes and strings for maximum breadth, but if they are truly strings, then this can be tightened.

Can be both, since on Linux, the bytes are directly passed on (via syspath returning early in that case).

wisp3rwind avatar Feb 12 '23 14:02 wisp3rwind

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 15 '23 07:12 stale[bot]