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

Add v1 future incompatibility warning #1801

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions holidays/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

# flake8: noqa: F403

import warnings

from holidays.constants import *
from holidays.deprecation import (
FUTURE_INCOMPATIBILITY_WARNING_TEMPLATE,
FutureIncompatibilityWarning,
)
from holidays.holiday_base import *
from holidays.registry import EntityLoader
from holidays.utils import *
Expand All @@ -22,3 +28,8 @@

EntityLoader.load("countries", globals())
EntityLoader.load("financial", globals())

warnings.warn(
FUTURE_INCOMPATIBILITY_WARNING_TEMPLATE.format(version=__version__),
FutureIncompatibilityWarning,
)
33 changes: 33 additions & 0 deletions holidays/deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# holidays
# --------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)

FUTURE_INCOMPATIBILITY_WARNING_TEMPLATE = """

This is a future version incompatibility warning from Python Holidays library v{version}
to inform you about an upcoming change in our API versioning strategy that may affect your
project's dependencies. Starting from version 1.0 onwards, we will be following a loose form of
Semantic Versioning (SemVer) to provide clearer communication regarding any potential breaking
changes.

This means that while we strive to maintain backward compatibility, there might be occasional
updates that introduce breaking changes to our API. To ensure the stability of your projects,
we highly recommend pinning the version of our API that you rely on. You can pin your current
holidays v0.x dependency (e.g., holidays=={version}) or limit it (e.g., holidays<1.0) in order to
avoid potentially unwanted upgrade to the version 1.0 when it's released (ETA 2024Q4 - 2025Q1).

If you have any questions or concerns regarding this change, please don't hesitate to reach out
to us via https://github.com/vacanza/python-holidays/discussions/1800.
"""


class FutureIncompatibilityWarning(DeprecationWarning):
pass
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ disable_error_code = ["override"]
module = "holidays.groups.*"
disable_error_code = "attr-defined"

[tool.pytest.ini_options]
addopts = "-p no:warnings"

[tool.rstcheck]
ignore_directives = ["automodule", "autosummary"]
ignore_languages = ["python"]
Expand Down
4 changes: 0 additions & 4 deletions tests/countries/test_eswatini.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,3 @@ def test_swaziland_deprecation_warning(self):
warnings.simplefilter("default")
with self.assertWarns(Warning):
holidays.Swaziland()

warnings.simplefilter("error")
with self.assertRaises(Warning):
holidays.Swaziland()
4 changes: 0 additions & 4 deletions tests/countries/test_south_korea.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,6 @@ def test_korea_deprecation_warning(self):
with self.assertWarns(Warning):
Korea()

warnings.simplefilter("error")
with self.assertRaises(Warning):
Korea()

def test_2020_all(self):
self.assertHolidays(
SouthKorea(categories=(BANK, PUBLIC), years=2020),
Expand Down
4 changes: 0 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@ deps =
commands =
pre-commit autoupdate
pre-commit run --all-files

[pytest]
filterwarnings =
ignore:The --rsyncdir .* are deprecated:DeprecationWarning