Skip to content

Commit

Permalink
Merge pull request #1542 from vacanza/beta
Browse files Browse the repository at this point in the history
v0.36
  • Loading branch information
arkid15r committed Nov 6, 2023
2 parents b64ae77 + cf3215c commit daa4b80
Show file tree
Hide file tree
Showing 99 changed files with 6,124 additions and 569 deletions.
99 changes: 66 additions & 33 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,56 @@
name: Tests
on: [merge_group, push, pull_request, workflow_dispatch]
name: CI/CD
on:
- merge_group
- pull_request
- push
- workflow_dispatch

env:
FORCE_COLOR: 1

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

jobs:
pre-commit:
name: Run Quality Assurance
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- name: Check Out Repository
- name: Check out Repository
uses: actions/checkout@v4
- name: Set Up Python

- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
python-version: '3.11'

- name: Run pre-commit
uses: pre-commit/action@v3.0.0

test:
name: 'Test: Python=${{ matrix.python-version }} on ${{ matrix.os }}'
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [pre-commit]
needs:
- pre-commit
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8']

os:
- macOS-latest
- ubuntu-latest
- windows-latest
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- 'pypy-3.9'
- 'pypy-3.10'
steps:
- uses: actions/checkout@v4
- name: Set Up Python ${{ matrix.python-version }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.7.1
with:
cache: pip
Expand All @@ -38,70 +59,82 @@ jobs:
requirements/tests.txt
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install Dependencies

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade --requirement requirements/tests.txt
python -m pip install .
- name: Run Tests
- name: Run tests
run: |
make test
- name: Upload Coverage
- name: Upload coverage
uses: coverallsapp/github-action@v2
with:
flag-name: tests-${{ matrix.python-version }}-${{ matrix.os }}
parallel: true
path-to-lcov: coverage.lcov

build:
name: Build Distribution
needs: [test]
name: Build distribution
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set Up Python

- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
cache: pip
cache-dependency-path: requirements/runtime.txt
python-version: '3.11'
- name: Install Dependencies

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build polib
pip install .
- name: Build Distribution
- name: Build distribution
run: |
make package
- name: Upload Package Artifacts
- name: Upload package artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

coveralls:
name: Finish Coveralls
needs: [test]
finish-coveralls:
name: Finish coveralls
needs: test
runs-on: ubuntu-latest
steps:
- name: Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

deploy:
name: Deploy
publish-pypi-main:
name: Publish to PyPI
if: |
github.repository == 'vacanza/python-holidays' &&
github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags/v')
environment: main
needs:
- build
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: [build]
steps:
- name: Get Package Artifacts
- name: Get package artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Publish Package
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
user: __token__
password: ${{ secrets.pypi_password }}

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
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.9.1
rev: 23.10.1
hooks:
- id: black
exclude: ^(docs)
Expand All @@ -35,7 +35,7 @@ repos:
exclude: ^(docs)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.0
rev: v1.6.1
hooks:
- id: mypy
additional_dependencies: [types-all]
Expand Down
24 changes: 24 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
Version 0.36
============

Released November 6, 2023

- Add special holidays per subdivisions support (#1520 by @KJhellico)
- Add special_holidays_observed support (#1535 by @KJhellico)
- Refactor Australia holidays (#1531 by @KJhellico)
- Refactor Isle of Man holidays (Tynwald Day) (#1532 by @KJhellico)
- Add Bahamas holidays (#1517 by @PPsyrius)
- Add Timor-Leste holidays (#1516 by @PPsyrius)
- Add Tonga holidays (#1534 by @PPsyrius)
- Update Portugal holidays: add holiday categories (#1529 by @KJhellico)
- Update South Africa holidays: add holiday in honor of Winning the Rugby World Cup 2023 (Dec 15, 2023) (#1538 by @KJhellico)
- Update snapshots generator (#1530 by @KJhellico)
- Add Thailand's Bridge Public Holiday on Dec 29, 2023 (#1528 by @PPsyrius)
- Migrate the remaining `special_holidays` to `StaticHolidays` class (#1519 by @PPsyrius)
- Remove hard-coding observed_rule for Bahamas (#1527 by @PPsyrius)
- Remove redundant gettext assignment (#1533 by @arkid15r)
- Set concurrency group for CI/CD jobs (#1540 by @arkid15r)
- Set pyproject.toml project version dynamically (#1525 by @arkid15r)
- Use OIDC (trusted publishers) for PyPI uploads (#1523 by @arkid15r)
- Use setdefault instead of hard-coding observed_rule and observed_since (#1521 by @BossColo)

Version 0.35
============

Expand Down
25 changes: 20 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ flexible as possible.
:target: https://pypi.python.org/pypi/holidays
:alt: Downloads

:CD/CI:
.. image:: https://github.com/vacanza/python-holidays/workflows/Tests/badge.svg
:CI/CD:
.. image:: https://github.com/vacanza/python-holidays/workflows/CI%2FCD/badge.svg
:target: actions

.. image:: http://img.shields.io/coveralls/vacanza/python-holidays/master
Expand Down Expand Up @@ -117,7 +117,7 @@ Available Countries
.. _ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
.. _ISO 639-2 code: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

We currently support 137 country codes. The standard way to refer to a country
We currently support 140 country codes. The standard way to refer to a country
is by using its `ISO 3166-1 alpha-2 code`_, the same used for domain names, and
for a subdivision its `ISO 3166-2 code`_. Some of the countries support more
than one language for holiday names output.
Expand Down Expand Up @@ -202,6 +202,11 @@ The list of supported countries, their subdivisions, supported languages and cat
-
-
-
* - Bahamas
- BS
-
-
-
* - Bahrain
- BH
-
Expand Down Expand Up @@ -664,9 +669,9 @@ The list of supported countries, their subdivisions, supported languages and cat
-
* - Portugal
- PT
- Districts: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 30, Ext; Use subdiv='Ext' to include holidays most people have off
- Districts: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 30
- en_US, **pt_PT**
-
- OPTIONAL, **PUBLIC**
* - Puerto Rico
- PR
- Can also be loaded as country US, subdivision PR
Expand Down Expand Up @@ -752,6 +757,16 @@ The list of supported countries, their subdivisions, supported languages and cat
-
- en_US, **th**
- ARMED_FORCES, BANK, GOVERNMENT, **PUBLIC**, SCHOOL, WORKDAY
* - Timor Leste
- TL
-
- en_US, **pt_TL**, tet
- GOVERNMENT, **PUBLIC**, WORKDAY
* - Tonga
- TO
-
- en_US, **to**
-
* - Tunisia
- TN
-
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.35"
__version__ = "0.36"


EntityLoader.load("countries", globals())
Expand Down
3 changes: 3 additions & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .australia import Australia, AU, AUS
from .austria import Austria, AT, AUT
from .azerbaijan import Azerbaijan, AZ, AZE
from .bahamas import Bahamas, BS, BHS
from .bahrain import Bahrain, BH, BAH
from .bangladesh import Bangladesh, BD, BGD
from .barbados import Barbados, BB, BRB
Expand Down Expand Up @@ -132,6 +133,8 @@
from .taiwan import Taiwan, TW, TWN
from .tanzania import Tanzania, TZ, TZA
from .thailand import Thailand, TH, THA
from .timor_leste import TimorLeste, TL, TLS
from .tonga import Tonga, TO, TON
from .tunisia import Tunisia, TN, TUN
from .turkey import Turkey, TR, TUR
from .ukraine import Ukraine, UA, UKR
Expand Down
13 changes: 7 additions & 6 deletions holidays/countries/albania.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars.gregorian import MAR
from holidays.calendars.gregorian import JAN, MAR
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.groups import (
ChristianHolidays,
Expand All @@ -36,7 +36,8 @@ def __init__(self, *args, **kwargs):
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self)
StaticHolidays.__init__(self, AlbaniaStaticHolidays)
super().__init__(observed_rule=SAT_SUN_TO_NEXT_WORKDAY, *args, **kwargs)
kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_WORKDAY)
super().__init__(*args, **kwargs)

def _populate(self, year):
super()._populate(year)
Expand Down Expand Up @@ -90,10 +91,6 @@ def _populate(self, year):
if self.observed:
self._populate_observed(dts_observed)

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


class AL(Albania):
pass
Expand All @@ -107,3 +104,7 @@ class AlbaniaStaticHolidays:
special_holidays = {
2022: (MAR, 21, "Public Holiday"),
}

special_holidays_observed = {
2007: (JAN, 3, "Eid al-Adha"),
}
19 changes: 12 additions & 7 deletions holidays/countries/angola.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Tuple

from holidays.calendars.gregorian import AUG, SEP, DEC
from holidays.groups import ChristianHolidays, InternationalHolidays
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
from holidays.observed_holiday_base import (
ObservedHolidayBase,
TUE_TO_PREV_MON,
Expand All @@ -23,7 +23,7 @@
)


class Angola(ObservedHolidayBase, ChristianHolidays, InternationalHolidays):
class Angola(ObservedHolidayBase, ChristianHolidays, InternationalHolidays, StaticHolidays):
"""
References:
- https://en.wikipedia.org/wiki/Public_holidays_in_Angola
Expand All @@ -45,15 +45,13 @@ class Angola(ObservedHolidayBase, ChristianHolidays, InternationalHolidays):
supported_languages = ("en_US", "pt_AO", "uk")
# %s (Observed).
observed_label = tr("%s (Ponte)")
special_holidays = {
# General Election Day.
2017: (AUG, 23, tr("Dia de eleições gerais")),
}

def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
super().__init__(observed_rule=TUE_TO_PREV_MON + THU_TO_NEXT_FRI, *args, **kwargs)
StaticHolidays.__init__(self, cls=AngolaStaticHolidays)
kwargs.setdefault("observed_rule", TUE_TO_PREV_MON + THU_TO_NEXT_FRI)
super().__init__(*args, **kwargs)

def _is_observed(self, dt: date) -> bool:
# As per Law # 16/96, from 1996/9/27, when public holiday falls on Sunday,
Expand Down Expand Up @@ -188,3 +186,10 @@ class AO(Angola):

class AGO(Angola):
pass


class AngolaStaticHolidays:
special_holidays = {
# General Election Day.
2017: (AUG, 23, tr("Dia de eleições gerais")),
}

0 comments on commit daa4b80

Please sign in to comment.