skypilot-org / skypilot

SkyPilot: Run AI and batch jobs on any infra (Kubernetes or 12+ clouds). Get unified execution, cost savings, and high GPU availability via a simple interface.
https://skypilot.readthedocs.io
Apache License 2.0
6.81k stars 513 forks source link

Replace `len()` Zero Checks with Pythonic Empty Sequence Checks #4298

Open andylizf opened 2 weeks ago

andylizf commented 2 weeks ago

Replace len() comparisons with 0/1 with pythonic empty sequence checks, following Google Python Style Guide's recommendation:

For sequences (strings, lists, tuples), use the fact that empty sequences are false, so if seq: and if not seq: are preferable to if len(seq): and if not len(seq): respectively.

Also fixed some typing annotations along the way.

Tested (run the relevant ones):

andylizf commented 2 weeks ago

@cblmemo PTAL, thanks!

Michaelvll commented 6 days ago

Please refer to the style guide: https://google.github.io/styleguide/pyguide.html#214-truefalse-evaluations

andylizf commented 6 days ago

@Michaelvll Precisely. As mentioned, this modification was just made based on the Google Python Style Guide. Please refer to: https://google.github.io/styleguide/pyguide.html#2144-decision.

andylizf commented 6 days ago

@Michaelvll By the way, when you have a moment, could you take a look at #4250 ? Thanks a lot!

Michaelvll commented 6 days ago

Ahh, thanks for fixing these! I misread the message. Looks pretty good at the first glance. cc'ing @cblmemo to take a closer look. : )