jazzband / prettytable

Display tabular data in a visually appealing ASCII table format
https://pypi.org/project/PrettyTable/
Other
1.32k stars 149 forks source link

Simplify empty dictionary/None check #286

Open himalayanZephyr opened 4 months ago

himalayanZephyr commented 4 months ago

Simplifying empty dictionary/None check

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.38%. Comparing base (6498a57) to head (54e690f).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #286 +/- ## ======================================= Coverage 94.38% 94.38% ======================================= Files 5 5 Lines 2404 2404 ======================================= Hits 2269 2269 Misses 135 135 ``` | [Flag](https://app.codecov.io/gh/jazzband/prettytable/pull/286/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jazzband) | Coverage Δ | | |---|---|---| | [macos-latest](https://app.codecov.io/gh/jazzband/prettytable/pull/286/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jazzband) | `94.34% <100.00%> (ø)` | | | [ubuntu-latest](https://app.codecov.io/gh/jazzband/prettytable/pull/286/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jazzband) | `94.34% <100.00%> (ø)` | | | [windows-latest](https://app.codecov.io/gh/jazzband/prettytable/pull/286/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jazzband) | `94.30% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jazzband#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

hugovk commented 4 months ago

And change the other six occurrences?

We can then also flip from:

if not val:
    ... # do when no val
else:
    ... # do when val

To:

if val:
    ... # do when val
else:
    ... # do when no val
hugovk commented 4 months ago

And can these be called when val is something that is not None or dict, but still evaluates to false here? And if so, does it behave correctly?

hugovk commented 1 month ago

@himalayanZephyr, please can you check the questions above?