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

Transition from pytz to zoneinfo #609

Closed
3 tasks done
Tracked by #630
niccokunzmann opened this issue Mar 27, 2024 · 3 comments
Closed
3 tasks done
Tracked by #630

Transition from pytz to zoneinfo #609

niccokunzmann opened this issue Mar 27, 2024 · 3 comments
Labels
nlnet Development is funded by NLNet & NGI Zero Core https://nlnet.nl/project/OpenWebCalendar

Comments

@niccokunzmann
Copy link
Member

niccokunzmann commented Mar 27, 2024

In EOL of Python 3.8 is 31st October 2024. Then, zoneinfo is the library that is shipped with Python. There are problems using pytz as timezone implementations have evolved. My proposal to solve this issue is the following:

  • create icalendar.set_default_timezone_implementation(TimeZone) where TimeZone can be pytz.Timezone or zoneinfo.ZoneInfo or others, taking a string like "UTC" or Europe/Berlin.
  • Allow a switch from zoneinfo to pytz by testing all timezone dependent tests with both implementations
  • a version 6 release after October will then switch from pytz to zoneinfo by setting another default and removing pytz altogether as a dependency. Tracked here: Version 6 - roadmap #630

What are your thoughts? Who thinks this will break existing code? What is needed for a transition?

See also:

Possibly related:

Code that needs touching:
The Timezone class contains logic to parse and create timezones from icalendar specifications:

class Timezone(Component):

@niccokunzmann
Copy link
Member Author

niccokunzmann commented Jun 4, 2024

Also:

  • Pytz has certain timezone names. We should support all of them with zoneinfo., see Zoneinfo #623 (comment)
  • Empty the timezone cache when switching timezone implementations.
  • Maybe, we can do a pre-release and ask people to test it and come back with ideas. - tracked in Version 6 - roadmap #630
  • make tzdata a dependency
  • document how to switch the timezone provider
  • run the tests with pytz as default and with zoneinfo as default (set at the start before any test is run) - we have global state. This is how we test that it really works with both versions.

For a new release:

@niccokunzmann niccokunzmann mentioned this issue Jun 4, 2024
3 tasks
@niccokunzmann
Copy link
Member Author

I created #623 to work on some improvements.

This was referenced Jun 18, 2024
@niccokunzmann
Copy link
Member Author

This is complete. We do not depend on pytz any more.

🥳

martimlobao pushed a commit to martimlobao/regybox that referenced this issue Sep 30, 2024
Bumps [icalendar](https://github.com/collective/icalendar) from 5.0.13
to 6.0.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/collective/icalendar/releases">icalendar's
releases</a>.</em></p>
<blockquote>
<h2>v6.0.0</h2>
<p>To view the changes, please see the <a
href="https://icalendar.readthedocs.io/en/latest/changelog.html">Changelog</a>.
This release can be installed from <a
href="https://pypi.org/project/icalendar/#history">PyPI</a>.</p>
<h2>v6.0.0a0</h2>
<p>To view the changes, please see the <a
href="https://icalendar.readthedocs.io/en/latest/changelog.html">Changelog</a>.
This release can be installed from <a
href="https://pypi.org/project/icalendar/#history">PyPI</a>.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/collective/icalendar/blob/main/CHANGES.rst">icalendar's
changelog</a>.</em></p>
<blockquote>
<h2>6.0.0 (2024-09-28)</h2>
<p>Minor changes:</p>
<ul>
<li>Add <code>__all__</code> variable to each modules in
<code>icalendar</code> package</li>
<li>Improve test coverage.</li>
<li>Adapt <code>test_with_doctest.py</code> to correctly run on
Windows.</li>
<li>Measure branch coverage when running tests.</li>
<li>Export <code>Component</code> base class for typing</li>
</ul>
<p>New features:</p>
<ul>
<li>Use <code>pyproject.toml</code> file instead of
<code>setup.py</code></li>
</ul>
<p>Bug fixes:</p>
<ul>
<li>Fix link to stable release of tox in documentation.</li>
<li>Fix a bad <code>bytes</code> replace in
<code>unescape_char</code>.</li>
<li>Handle <code>ValueError</code> in
<code>vBinary.from_ical</code>.</li>
<li>Ignore the BOM character in incorrectly encoded ics files.</li>
</ul>
<h2>6.0.0a0 (2024-07-03)</h2>
<p>Minor changes:</p>
<ul>
<li>Test that all code works with both <code>pytz</code> and
<code>zoneinfo</code>.</li>
<li>Add message to GitHub release, pointing to the changelog</li>
<li>Make coverage report submission optional for pull requests</li>
<li>Parallelize coverage</li>
<li>Rename <code>master</code> branch to <code>main</code>, see
<code>Issue
&lt;https://github.com/collective/icalendar/issues/627&gt;</code>_</li>
<li>Update <code>docs/usage.rst</code> to use zoneinfo instead of
pytz.</li>
<li>Added missing public classes and functions to API
documentation.</li>
<li>Improved namespace management in the <code>icalendar</code>
directory.</li>
<li>Add Python version badge and badge for test coverage</li>
<li>Remove 4.x badge</li>
<li>Update list of <code>tox</code> environments</li>
<li>Use Coveralls' GitHub Action</li>
<li>Check distribution in CI</li>
</ul>
<p>Breaking changes:</p>
<ul>
<li>
<p>Use <code>zoneinfo</code> for <code>icalendar</code> objects created
from strings,
see <code>Issue
[#609](collective/icalendar#609)
&lt;https://github.com/collective/icalendar/issues/609&gt;</code>_.</p>
<p>This is an tested extension of the functionality, not a restriction:
If you create <code>icalendar</code> objects with <code>pytz</code>
timezones in your code,
<code>icalendar</code> will continue to work in the same way.</p>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/collective/icalendar/commit/37c522be8609e9df0808da2c1c7e2ccc9c38a54c"><code>37c522b</code></a>
Merge pull request <a
href="https://redirect.github.com/collective/icalendar/issues/710">#710</a>
from niccokunzmann/release</li>
<li><a
href="https://github.com/collective/icalendar/commit/354a6e03297b48b8f52b4a78aefa3634bd8b0fee"><code>354a6e0</code></a>
update maintenance to v6</li>
<li><a
href="https://github.com/collective/icalendar/commit/0f210f8bef5246eae3c52f5218e5a7998e623dbd"><code>0f210f8</code></a>
Fix install.rst again</li>
<li><a
href="https://github.com/collective/icalendar/commit/e48dcfbff90a3f27f8c3480eed210a8010b5020a"><code>e48dcfb</code></a>
Fix the doctests</li>
<li><a
href="https://github.com/collective/icalendar/commit/2f47800fb9f28e7929486fa2ad21a8018cb9b661"><code>2f47800</code></a>
correct install.rst</li>
<li><a
href="https://github.com/collective/icalendar/commit/443519c7c420c475f5d680ffe47d21c3d8d564f9"><code>443519c</code></a>
alpha -&gt; stable</li>
<li><a
href="https://github.com/collective/icalendar/commit/4673e04c1e91ba59c90b36b1ed36fa02bc933d70"><code>4673e04</code></a>
remove the version update as this is now done by tags</li>
<li><a
href="https://github.com/collective/icalendar/commit/17dba94ba4453a2bc3bf82ce9aef078f342051b1"><code>17dba94</code></a>
Update changes for release</li>
<li><a
href="https://github.com/collective/icalendar/commit/ca260c86d66a7d50a1a0243d1d7e6e15933cc292"><code>ca260c8</code></a>
Merge pull request <a
href="https://redirect.github.com/collective/icalendar/issues/707">#707</a>
from niccokunzmann/issue-686-pyproject.toml</li>
<li><a
href="https://github.com/collective/icalendar/commit/cc4635ff397250620be33f0d75ececf2d20bdde0"><code>cc4635f</code></a>
Document outdated email</li>
<li>Additional commits viewable in <a
href="https://github.com/collective/icalendar/compare/v5.0.13...v6.0.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=icalendar&package-manager=pip&previous-version=5.0.13&new-version=6.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nlnet Development is funded by NLNet & NGI Zero Core https://nlnet.nl/project/OpenWebCalendar
Projects
None yet
Development

No branches or pull requests

1 participant