Skip to content

Commit

Permalink
Merge pull request #1477 from vacanza/beta
Browse files Browse the repository at this point in the history
v.0.33
  • Loading branch information
KJhellico committed Sep 18, 2023
2 parents 7519898 + 082a8b3 commit 39f555a
Show file tree
Hide file tree
Showing 144 changed files with 3,294 additions and 2,064 deletions.
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/setup-python@v4.7.0
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/setup-python@v4.7.0
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/setup-python@v4.7.0
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/setup-python@v4.7.0
with:
python-version: "3.11"
- uses: browniebroke/pre-commit-autoupdate-action@v1.0.0
- uses: peter-evans/create-pull-request@v5.0.2
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

0 comments on commit 39f555a

Please sign in to comment.