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

remove pytz #1442

Closed
wants to merge 1 commit into from
Closed

remove pytz #1442

wants to merge 1 commit into from

Conversation

deronnax
Copy link

@deronnax deronnax commented Oct 28, 2024

To keep it simple, I made it so it imply to drop support for python 3.8, which is already OEL.
Though, I still have this error I am not sure about:

tests/test_xsd_builtins.py:158 (TestDateTime.test_xmlvalue)
'2016-03-04T21:14:42+00:00' != '2016-03-04T21:14:42Z'

Expected :'2016-03-04T21:14:42Z'
Actual   :'2016-03-04T21:14:42+00:00'

<Click to see difference>


self = <tests.test_xsd_builtins.TestDateTime object at 0x1036aa090>

    def test_xmlvalue(self):
        instance = builtins.DateTime()
        value = datetime.datetime(2016, 3, 4, 21, 14, 42)
        assert instance.xmlvalue(value) == "2016-03-04T21:14:42"
    
        value = datetime.datetime(2016, 3, 4, 21, 14, 42, tzinfo=timezone.utc)
>       assert instance.xmlvalue(value) == "2016-03-04T21:14:42Z"
E       AssertionError: assert '2016-03-04T21:14:42+00:00' == '2016-03-04T21:14:42Z'
E         
E         - 2016-03-04T21:14:42Z
E         ?                    ^
E         + 2016-03-04T21:14:42+00:00
E         ?                    ^^^^^^

tests/test_xsd_builtins.py:165: AssertionError

@deronnax
Copy link
Author

OK I know why, it's because isodate has a formatting logic that do not recognize python's UTC tzinfo objects: their .dst() method return None, isodate expects a timedelta(0) to consider them UTC.

  • either we use isodate's tzinfo everywhere instead of python's one, but that would be a move backward
  • either we need to find something so we can get the UTC datetime formatting to have a trailing Z for UTC datetime, because it's not doable out of the box with python standard datetimes.

@JuneStepp
Copy link

OK I know why, it's because isodate has a formatting logic that do not recognize python's UTC tzinfo objects: their .dst() method return None, isodate expects a timedelta(0) to consider them UTC.

* either we use isodate's tzinfo everywhere instead of python's one, but that would be a move backward

* either we need to find something so we can get the UTC datetime formatting to have a trailing `Z` for UTC datetime, because it's not doable out of the box with python standard datetimes.

See this commit from my fork: c16230e

@deronnax
Copy link
Author

Wow, that's a good work, maybe better than mine. Mind giving your work for #1420 ?

@JuneStepp
Copy link

Wow, that's a good work, maybe better than mine. Mind giving your work for #1420 ?

#1443 should do it. zoneinfo isn't actually needed, so I didn't change the Python version requirements.

@deronnax
Copy link
Author

closing because #1443 is superior.

@deronnax deronnax closed this Nov 14, 2024
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.

2 participants