Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove pyrfc3339 and change to datetime.datetime.fromisoformat… #1247

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EdmilsonRodrigues
Copy link
Contributor

…() and datetime.datetime.isoformat()

Description

I tried using backports.datetime_fromisoformat but than the tox tests broke, probably because it required an import in the unit tests. I tried than just using the usual builtin datetime.datetime.fromisoformat and it worked just well.

<Fixes: >

QA Steps

<Commands / tests / steps to run to verify that the change works:>

tox -e py3 -- tests/unit/...
tox -e integration -- tests/integration/...

All CI tests need to pass.

<Please note that most likely an additional test will be required by the reviewers for any change that's not a one liner to land.>

Notes & Discussion

*This is a secondary branch from the Pull Request #1243 *

@james-garner-canonical
Copy link
Contributor

I tried using backports.datetime_fromisoformat but than the tox tests broke, probably because it required an import in the unit tests

Yeah unfortunately we currently need to specify the dependencies in both pyproject.toml and tox.ini we can add backports-datetime-fromisoformat -- you can replace the pyRFC339 dependency in both

I tried than just using the usual builtin datetime.datetime.fromisoformat and it worked just well

I'm guessing you're using python 3.11+ locally -- datetime.fromisoformat was extended in 3.11 to properly support the format rather than just the subset output by datetime. We need to support python 3.8+, and as you can (now) see from the CI run, unit tests for the cookie handling fail on python > 3.11. Hence the need for the backports dependency

BTW as an external contributor your PRs against this repo don't have our CI run automatically, but I believe that you should be able to open a PR against your own fork's main first and have the tests run there -- this will take care of running linting and running tests against multiple python and juju versions

@james-garner-canonical
Copy link
Contributor

Btw @EdmilsonRodrigues we most likely won't be looking at PRs over the next couple of weeks due to the holiday season but happy to continue after that -- thanks for your contributions so far

@dimaqq
Copy link
Contributor

dimaqq commented Dec 20, 2024

I'm sorry about our CI:

   input: chore: remove pyrfc3339 and change to datetime.datetime.fromisoformat() and datetime.datetime.isoformat()
✖   header must not be longer than 100 characters, current length is 105 [header-max-length]

Please amend the commit message 🙇🏻

@EdmilsonRodrigues
Copy link
Contributor Author

I tried to open a PR to my own main branch but no test was created. I think I need to configure the github actions. I'll learn how to do it and do it for the next time.

Also merry holidays for you all!!!

tox.ini Outdated Show resolved Hide resolved
juju/__init__.py Outdated Show resolved Hide resolved
juju/__init__.py Outdated Show resolved Hide resolved
@dimaqq
Copy link
Contributor

dimaqq commented Jan 15, 2025

Please rebase 🙇🏻

@james-garner-canonical
Copy link
Contributor

Thanks for this, @EdmilsonRodrigues. If you can rebase from main and fix your commit messages (or squash them) to use conventional commits (using commit types from the example at that page), then I think we can go ahead and merge this

@EdmilsonRodrigues EdmilsonRodrigues force-pushed the backports branch 2 times, most recently from 4bbfa6d to c0dfa92 Compare January 27, 2025 11:41
@EdmilsonRodrigues
Copy link
Contributor Author

I'm really sorry if I'm not doing this right. I'm still learning how to do rebasing and working in a project like this.

I think it worked now.

@EdmilsonRodrigues
Copy link
Contributor Author

Thank you for all the guidance during this process.
I think it's done now.
But, for later moments, how can I see that view that you just showed me to see if I'm doing it right?

tox.ini Outdated Show resolved Hide resolved
@dimaqq
Copy link
Contributor

dimaqq commented Jan 29, 2025

The command I used was git log --all --decorate --oneline --graph.

rebase: is not a conventional commit type, pls mark it as chore or something.

@dimaqq
Copy link
Contributor

dimaqq commented Jan 29, 2025

input: refacor: change monkeypatch to use local imports
✖ type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] [type-enum]

@dimaqq
Copy link
Contributor

dimaqq commented Jan 29, 2025

A simple fix would be to squash all your commits into one and update the commit message.

got rebase -i main and follow the editor prompt

@EdmilsonRodrigues
Copy link
Contributor Author

When I used this, it let me rename all my commits, because I still haven't learned how to squash, but I'll study more git this month so the problems I faced with this PR won't happen again in the next one, sorry again.

@dimaqq
Copy link
Contributor

dimaqq commented Jan 30, 2025

No worries, you'll get a hang of it as you contribute to open source more.

@dimaqq
Copy link
Contributor

dimaqq commented Jan 30, 2025

⧗   input: chore: remove pyrfc3339 and change to datetime.datetime.fromisoformat() and datetime.datetime.isoformat()
✖   header must not be longer than 100 characters, current length is 105 [header-max-length]

I'm sorry for silly rules that this repo imposes. I'm helping maintain it, but I didn't start it or invent these rules.

@dimaqq
Copy link
Contributor

dimaqq commented Jan 30, 2025

I think when you've rebased last, your main was not up to date with upstream (juju) main.

* 3aa4221 (edmilson/backports) chore: remove deps backports-datetime-fromisoformat
* 59e3cd4 chore: rebase with main
* 62fcdb2 refactor: change monkeypatch to use local imports
* 6814f06 chore: remove pyrfc3339 and change to datetime.datetime.fromisoformat() and datetime.datetime.isoformat()
* e5d384d refactor: change monkeypatch to use local imports
* 172590a chore: change setup.py to use backports instead of pyrfc
* 1d9d6ba chore: added backports to tox.ini and pyproject.toml
* d1abfa8 chore: remove pyrfc3339 and change to datetime.datetime.fromisoformat() and datetime.datetime.isoformat()
| *   1907f7a (upstream/main, origin/main, main) Merge pull request #1250 from dimaqq/upstream-type-fixes
| |\
| |/
|/|
* | e7bcdc9 (edmilson/main, upstream-type-fixes) chore: don't allow 0.25.2 either, still broken
* | 2423ef7 chore: block broken(?) pytest-asyncio version
* | 35ba68b chore: type hint improvements from the helper thread branch
|/
*   a58645e Merge pull request #1244 from tmihoc/add-discourse-docs

@dimaqq
Copy link
Contributor

dimaqq commented Jan 30, 2025

Or maybe you've made the mistake of merging upstream main into your main or cherry-picked specific commits.

Typically what I would do in this case is git checkout main && git reset --hard upstream/main.

Or you can rebase your branch on top of upstream/main directly. Up to you.

chore: added backports to tox.ini and pyproject.toml

chore: change setup.py to use backports instead of pyrfc

refactor: change monkeypatch to use local imports

chore: change pyrfc3339 to backports.from_isoformat

refactor: change monkeypatch to use local imports

chore: rebase with main

chore: remove deps backports-datetime-fromisoformat
@EdmilsonRodrigues
Copy link
Contributor Author

Thank you for your pacience and guidance. I am really thankful for that.
I think I learned how to squash, Let's see if ti works now, but I rebase, and I think it worked this time.

# Note: fromtimestamp bizarrely produces a time without
# a time zone, so we need to use accept_naive.
go_cookie["Expires"] = pyrfc3339.generate(unix_time, accept_naive=True)
go_cookie["Expires"] = datetime.datetime.fromtimestamp(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the output exactly same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly, these are the outputs:
pyrfc3339: 2025-01-30T14:49:41Z
datetime.isoformat(): 2025-01-30T14:49:41.562687

But this was already discussed, I think in the other PR about the same issue, but as both are different formats that are part of the RFC3339 specification, we decided to proceed.

But if it's not possible, I can find another solution. There was also that manual parse I did to make them equal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just something I need to be clear about and run by juju (server) folks.

@SimonRichardson wdyt? or nominate someone, pls.

@dimaqq
Copy link
Contributor

dimaqq commented Jan 31, 2025

/build

@dimaqq dimaqq self-requested a review January 31, 2025 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants