PyBites-Open-Source / pybites-tools

A repo to commit common Python utility scripts and snippets
MIT License
18 stars 8 forks source link

fix hour check in worldclock.py: #26

Closed fischa closed 2 years ago

fischa commented 2 years ago
fischa commented 2 years ago

Before:

(workspace) ➜  workspace git:(master) ✗ python -m pybites_tools.worldclock -hr 23
America/Vancouver         16:55 -0700 (PDT)
America/Phoenix           16:55 -0700 (MST)
America/New_York          19:55 -0400 (EDT)
UTC                       23:55 +0000 (UTC)
Europe/Berlin             01:55 +0200 (CEST)
Asia/Singapore            07:55 +0800 (+08)
Australia/Sydney          09:55 +1000 (AEST)
(workspace) ➜  workspace git:(master) ✗ python -m pybites_tools.worldclock -hr 0
America/Vancouver         03:56 -0700 (PDT)
America/Phoenix           03:56 -0700 (MST)
America/New_York          06:56 -0400 (EDT)
UTC                       10:56 +0000 (UTC)
Europe/Berlin             12:56 +0200 (CEST)
Asia/Singapore            18:56 +0800 (+08)
Australia/Sydney          20:56 +1000 (AEST)

After:

(pybites-tools) ➜  pybites-tools git:(main) ✗ python -m pybites_tools.worldclock -hr 23
America/Vancouver         03:56 -0700 (PDT)
America/Phoenix           03:56 -0700 (MST)
Europe/London             11:56 +0100 (BST)
UTC                       10:56 +0000 (UTC)
Europe/Berlin             12:56 +0200 (CEST)
Asia/Singapore            18:56 +0800 (+08)
Australia/Sydney          20:56 +1000 (AEST)
(pybites-tools) ➜  pybites-tools git:(main) ✗ python -m pybites_tools.worldclock -hr 0
America/Vancouver         17:56 -0700 (PDT)
America/Phoenix           17:56 -0700 (MST)
Europe/London             01:56 +0100 (BST)
UTC                       00:56 +0000 (UTC)
Europe/Berlin             02:56 +0200 (CEST)
Asia/Singapore            08:56 +0800 (+08)
Australia/Sydney          10:56 +1000 (AEST)
fischa commented 2 years ago

Not sure why black in the CI failed:

(pybites-tools) ➜  pybites-tools git:(fix-hour-check-worldclock) ✗ git commit
Check Yaml...........................................(no files to check)Skipped
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
black....................................................................Passed
[fix-hour-check-worldclock d6de79f] fix hour check in worldclock.py:
 1 file changed, 3 insertions(+), 3 deletions(-)
fischa commented 2 years ago
(pybites-tools) ➜  pybites-tools git:(main) black pybites_tools/worldclock.py
All done! ✨ 🍰 ✨
1 file left unchanged.

But I'm running python 3.9.10 - maybe the version in CI needs to be bumped?

bbelderbos commented 2 years ago

@rhyspowell could you check the CI part please? I think you set it up, why are we running black, shouldn't that be local only? Thanks

fischa commented 2 years ago

Doh! I totally missed that (range issue). Now it is working as expected:

(pybites-tools) ➜  pybites-tools git:(fix-hour-check-worldclock) python -m pybites_tools.worldclock -hr 23
America/Vancouver         22:49 -0700 (PDT)
America/Phoenix           22:49 -0700 (MST)
Europe/London             06:49 +0100 (BST)
UTC                       05:49 +0000 (UTC)
Europe/Berlin             07:49 +0200 (CEST)
Asia/Singapore            13:49 +0800 (+08)
Australia/Sydney          15:49 +1000 (AEST)
(pybites-tools) ➜  pybites-tools git:(fix-hour-check-worldclock) code pybites_tools/worldclock.py
(pybites-tools) ➜  pybites-tools git:(fix-hour-check-worldclock) python -m pybites_tools.worldclock -hr 23
America/Vancouver         16:59 -0700 (PDT)
America/Phoenix           16:59 -0700 (MST)
Europe/London             00:59 +0100 (BST)
UTC                       23:59 +0000 (UTC)
Europe/Berlin             01:59 +0200 (CEST)
Asia/Singapore            07:59 +0800 (+08)
Australia/Sydney          09:59 +1000 (AEST)
bbelderbos commented 2 years ago

Doh! I totally missed that (range issue). Now it is working as expected:

(pybites-tools) ➜  pybites-tools git:(fix-hour-check-worldclock) python -m pybites_tools.worldclock -hr 23
America/Vancouver         22:49 -0700 (PDT)
America/Phoenix           22:49 -0700 (MST)
Europe/London             06:49 +0100 (BST)
UTC                       05:49 +0000 (UTC)
Europe/Berlin             07:49 +0200 (CEST)
Asia/Singapore            13:49 +0800 (+08)
Australia/Sydney          15:49 +1000 (AEST)
(pybites-tools) ➜  pybites-tools git:(fix-hour-check-worldclock) code pybites_tools/worldclock.py
(pybites-tools) ➜  pybites-tools git:(fix-hour-check-worldclock) python -m pybites_tools.worldclock -hr 23
America/Vancouver         16:59 -0700 (PDT)
America/Phoenix           16:59 -0700 (MST)
Europe/London             00:59 +0100 (BST)
UTC                       23:59 +0000 (UTC)
Europe/Berlin             01:59 +0200 (CEST)
Asia/Singapore            07:59 +0800 (+08)
Australia/Sydney          09:59 +1000 (AEST)

Fact it did not failed a test means we probably also want to write a test for that then :)

rhyspowell commented 2 years ago

@bbelderbos Thats something you added as part of precommit, I just made it work ;)

I suspect it would work if you bumped the rev to 22.3.0 or you could just delete it

bbelderbos commented 2 years ago

precommit

But precommit is local? Where is the pre-commit.ci coming from?

rhyspowell commented 2 years ago

https://github.com/PyBites-Open-Source/pybites-tools/blob/main/.pre-commit-config.yaml

bbelderbos commented 2 years ago

https://github.com/PyBites-Open-Source/pybites-tools/blob/main/.pre-commit-config.yaml

Sorry, should have googled the error, you are right: https://github.com/psf/black/issues/2964 - I updated the yml file updating the versions of the tools, that should fix it.