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

v.0.33 #1477

Merged
merged 21 commits into from
Sep 18, 2023
Merged

v.0.33 #1477

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
110e3cc
Initialize v0.33
arkid15r Sep 4, 2023
14a8cfa
Introduce ObservedHolidays class (#1444)
KJhellico Sep 5, 2023
927f298
Bump actions/checkout from 3 to 4 (#1458)
dependabot[bot] Sep 7, 2023
8fc7271
Update skipIf rules for heavy tests (#1460)
arkid15r Sep 7, 2023
d2fe963
Update PR template (#1461)
arkid15r Sep 7, 2023
424505a
Add merge queue support (#1464)
arkid15r Sep 8, 2023
e841412
Update Canada holidays (#1448)
KJhellico Sep 11, 2023
ce88c1b
Update Brazil holidays: specify optional holidays (#1452)
KJhellico Sep 11, 2023
7ce0b50
Update United Kingdom holidays (#1454)
KJhellico Sep 12, 2023
f239ad5
Update l10n files: fix ar, en_US headers (#1468)
abh31000 Sep 12, 2023
56f7732
Update examples.rst (#1456)
jovana Sep 12, 2023
06bc39f
Update Thailand holidays: add holiday categories (#1346)
PPsyrius Sep 12, 2023
0b40a49
Update pre commit automatic update workflow (#1469)
arkid15r Sep 13, 2023
c3bac47
Update pre-commit hooks (#1470)
github-actions[bot] Sep 13, 2023
02aa5d6
Update Belgium holidays: add bank holidays (#1457)
KJhellico Sep 15, 2023
1f03de3
Update Liechtenstein holidays: specify bank holidays (#1462)
KJhellico Sep 15, 2023
df19d58
Migrate remaining countries to ObservedHolidayBase (#1463)
KJhellico Sep 15, 2023
5807a79
Update Algeria holidays: add fr localization (#1467)
abh31000 Sep 15, 2023
21f9b1c
Fix README.rst (#1472)
KJhellico Sep 15, 2023
00935bf
Tune pre-commit auto-update workflow (#1473)
arkid15r Sep 15, 2023
082a8b3
Finalize v0.33
KJhellico Sep 18, 2023
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
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ Your PR description goes here.
-->

- [ ] I've followed the [contributing guidelines][contributing-guidelines]
- [ ] I've added references to all holidays information sources used in this PR
- [ ] This PR is filed against `beta` branch of the repository
- [ ] This PR doesn't contain any merge conflicts and has clean commit history
- [ ] The code style looks good: `make pre-commit`
- [ ] The code style looks good: `make pre-commit` command generates no changes
- [ ] All tests pass locally: `make test`, `make tox` (we strongly encourage adding tests to your code)
- [ ] The related [documentation][docs] has been added/updated (check off the box for free if no updates is required)

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Tests
on: [push, pull_request, workflow_dispatch]
on: [merge_group, push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1
Expand All @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check Out Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set Up Python
uses: actions/[email protected]
with:
Expand All @@ -28,7 +28,7 @@ jobs:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set Up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set Up Python
uses: actions/[email protected]
with:
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/pre-commit-autoupdate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pre-commit hooks autoupdate
name: Update pre-commit hooks

on:
schedule:
Expand All @@ -7,18 +7,25 @@ on:

jobs:
auto-update:
name: Update pre-commit hooks
if: ${{ github.repository }} == "vacanza/python-holidays"
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
python-version: "3.11"
- uses: browniebroke/[email protected]
- uses: peter-evans/[email protected]
with:
base: beta
branch: update/pre-commit-hooks
title: Update pre-commit hooks
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
body: Update pre-commit hooks to their latest versions.
branch: update-pre-commit-hooks
commit-message: "Chore: Update pre-commit hooks"
committer: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
body: Update versions of pre-commit hooks to latest version.
delete-branch: true
title: Update pre-commit hooks
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
exclude: ^(docs)
Expand Down Expand Up @@ -50,7 +50,7 @@ repos:
- id: rst-backticks

- repo: https://github.com/myint/rstcheck
rev: v6.1.2
rev: v6.2.0
hooks:
- id: rstcheck
additional_dependencies: [rstcheck, sphinx]
Expand Down
23 changes: 23 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
Version 0.33
============

Released September 18, 2023

- Add merge queue support (#1464 by @arkid15r)
- Introduce ObservedHolidays class (#1444 by @KJhellico, @arkid15r)
- Update Algeria holidays: add fr localization (#1467 by @abh31000)
- Fix README.rst (#1472 by @KJhellico)
- Update Belgium holidays: add bank holidays (#1457 by @KJhellico)
- Update Brazil holidays: specify optional holidays (#1452 by @KJhellico)
- Update Canada holidays (#1448 by @KJhellico)
- Update Liechtenstein holidays: specify bank holidays (#1462 by @KJhellico)
- Update PR template (#1461 by @arkid15r)
- Update Thailand holidays: add holiday categories (#1346 by @PPsyrius, @arkid15r, @KJhellico)
- Update United Kingdom holidays (#1454 by @KJhellico)
- Update documentation: add language usage example to examples.rst (#1456 by @jovana, @arkid15r, @KJhellico)
- Update l10n files: fix ar, en_US headers (#1468 by @abh31000)
- Update pre commit automatic update workflow (#1469 by @arkid15r)
- Update skipIf rules for heavy tests (#1460 by @arkid15r)
- Migrate remaining countries to ObservedHolidayBase (#1463 by @KJhellico)
- Tune pre-commit auto-update workflow (#1473 by @arkid15r)

Version 0.32
============

Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Install

The latest stable version can always be installed or updated via pip:

.. code-block:: bash
.. code-block:: shell

$ pip install --upgrade holidays

Expand Down Expand Up @@ -140,7 +140,7 @@ The list of supported countries, their subdivisions and supported languages
* - Algeria
- DZ
-
- **ar**, en_US
- **ar**, en_US, fr
* - American Samoa
- AS
- Can also be loaded as country US, subdivision AS
Expand Down Expand Up @@ -243,7 +243,7 @@ The list of supported countries, their subdivisions and supported languages
-
* - Canada
- CA
- Provinces and territories: AB, BC, MB, NB, NL, NS, NT, NU, **ON**, PE, QC, SK, YT
- Provinces and territories: AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YT
- ar, **en**, fr, th
* - Chad
- TD
Expand Down Expand Up @@ -705,7 +705,7 @@ Beta Version

The latest development (beta) version can be installed directly from GitHub:

.. code-block:: bash
.. code-block:: shell

$ pip install --upgrade https://github.com/vacanza/python-holidays/tarball/beta

Expand Down
19 changes: 19 additions & 0 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ fly and the holiday list will be adjusted accordingly:
>> date(2012, 1, 2) in us_holidays
True

Language support
----------------
To change the language translation, you can set the language explicitly.

.. code-block:: python

>>> for dt, name in sorted(holidays.ES(years=2023, language="es").items()):
>>> print(dt, name)
2023-01-06 Epifanía del Señor
2023-04-06 Jueves Santo
2023-04-07 Viernes Santo
2023-05-01 Día del Trabajador
2023-08-15 Asunción de la Virgen
2023-10-12 Día de la Hispanidad
2023-11-01 Todos los Santos
2023-12-06 Día de la Constitución Española
2023-12-08 La Inmaculada Concepción
2023-12-25 Navidad


Date from holiday name
----------------------
Expand Down
2 changes: 1 addition & 1 deletion holidays/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from holidays.registry import EntityLoader
from holidays.utils import *

__version__ = "0.32"
__version__ = "0.33"


EntityLoader.load("countries", globals())
Expand Down
6 changes: 4 additions & 2 deletions holidays/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
HOLIDAY_NAME_DELIMITER = "; " # Holiday names separator.

# Supported holiday categories.
ARMED_FORCES = "armed_forces"
BANK = "bank"
EXTENDED = "extended"
GOVERNMENT = "government"
HALF_DAY = "half_day"
OPTIONAL = "optional"
PUBLIC = "public"
SCHOOL = "school"
WORKDAY = "workday"
Expand All @@ -52,15 +53,16 @@
ISLAMIC = "islamic"

ALL_CATEGORIES = {
ARMED_FORCES,
BANK,
CHINESE,
CHRISTIAN,
EXTENDED,
GOVERNMENT,
HALF_DAY,
HEBREW,
HINDU,
ISLAMIC,
OPTIONAL,
PUBLIC,
SCHOOL,
WORKDAY,
Expand Down
58 changes: 25 additions & 33 deletions holidays/countries/albania.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from datetime import timedelta as td

from holidays.calendars.gregorian import MAR
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.groups import ChristianHolidays, IslamicHolidays, InternationalHolidays
from holidays.holiday_base import HolidayBase
from holidays.groups import ChristianHolidays, InternationalHolidays, IslamicHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SAT_SUN_TO_NEXT_WORKDAY


class Albania(HolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays):
class Albania(ObservedHolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolidays):
"""
References:
- https://en.wikipedia.org/wiki/Public_holidays_in_Albania
"""

country = "AL"
observed_label = "%s (Observed)"
special_holidays = {
2022: (MAR, 21, "Public Holiday"),
}
Expand All @@ -32,70 +31,63 @@ def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self)
super().__init__(*args, **kwargs)
super().__init__(observed_rule=SAT_SUN_TO_NEXT_WORKDAY, *args, **kwargs)

def _populate(self, year):
super()._populate(year)
observed_dates = set()
dts_observed = set()

# New Year's Day.
name = "New Year's Day"
observed_dates.add(self._add_new_years_day(name))
observed_dates.add(self._add_new_years_day_two(name))
dts_observed.add(self._add_new_years_day(name))
dts_observed.add(self._add_new_years_day_two(name))

# Summer Day.
if year >= 2004:
observed_dates.add(self._add_holiday_mar_14("Summer Day"))
dts_observed.add(self._add_holiday_mar_14("Summer Day"))

# Nevruz.
if year >= 1996:
observed_dates.add(self._add_holiday_mar_22("Nevruz"))
dts_observed.add(self._add_holiday_mar_22("Nevruz"))

# Easter.
observed_dates.add(self._add_easter_sunday("Catholic Easter"))
observed_dates.add(self._add_easter_sunday("Orthodox Easter", JULIAN_CALENDAR))
dts_observed.add(self._add_easter_sunday("Catholic Easter"))
dts_observed.add(self._add_easter_sunday("Orthodox Easter", JULIAN_CALENDAR))

# May Day.
observed_dates.add(self._add_labor_day("May Day"))
dts_observed.add(self._add_labor_day("May Day"))

# Mother Teresa Day.
if 2004 <= year <= 2017:
observed_dates.add(self._add_holiday_oct_19("Mother Teresa Beatification Day"))
dts_observed.add(self._add_holiday_oct_19("Mother Teresa Beatification Day"))
elif year >= 2018:
observed_dates.add(self._add_holiday_sep_5("Mother Teresa Canonization Day"))
dts_observed.add(self._add_holiday_sep_5("Mother Teresa Canonization Day"))

# Independence Day.
observed_dates.add(self._add_holiday_nov_28("Independence Day"))
dts_observed.add(self._add_holiday_nov_28("Independence Day"))

# Liberation Day.
observed_dates.add(self._add_holiday_nov_29("Liberation Day"))
dts_observed.add(self._add_holiday_nov_29("Liberation Day"))

# National Youth Day.
if year >= 2009:
observed_dates.add(self._add_holiday_dec_8("National Youth Day"))
dts_observed.add(self._add_holiday_dec_8("National Youth Day"))

# Christmas Day.
observed_dates.add(self._add_christmas_day("Christmas Day"))
dts_observed.add(self._add_christmas_day("Christmas Day"))

# Eid al-Fitr.
observed_dates.update(self._add_eid_al_fitr_day("Eid al-Fitr"))
dts_observed.update(self._add_eid_al_fitr_day("Eid al-Fitr"))

# Eid al-Adha.
observed_dates.update(self._add_eid_al_adha_day("Eid al-Adha"))
dts_observed.update(self._add_eid_al_adha_day("Eid al-Adha"))

if self.observed:
for dt in sorted(observed_dates):
if not self._is_weekend(dt):
continue
dt_observed = dt + td(days=+1)
while self._is_weekend(dt_observed) or dt_observed in observed_dates:
dt_observed += td(days=+1)
for name in self.get_list(dt):
observed_dates.add(self._add_holiday("%s (Observed)" % name, dt_observed))

# observed holidays special cases
self._populate_observed(dts_observed)

# Observed holidays special cases.
if year == 2007:
self._add_holiday_jan_3("Eid al-Adha (Observed)")
self._add_holiday_jan_3(self.observed_label % "Eid al-Adha")


class AL(Albania):
Expand Down
Loading