diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 099b60c77..f5f26b89a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,11 +60,6 @@ repos: hooks: - id: tox-ini-fmt - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.4.0 - hooks: - - id: setup-cfg-fmt - - repo: local hooks: - id: tests diff --git a/MANIFEST.in b/MANIFEST.in index f0f9c5c6b..32e70e428 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,8 +1,11 @@ include CHANGES -include holidays/py.typed +include CONTRIBUTING.rst +include Makefile + recursive-include docs * -recursive-include holidays *.py recursive-include holidays/locale *.mo recursive-include holidays/locale *.po -recursive-include scripts/l10n *.py -recursive-include tests *.py +recursive-include requirements * + +prune docs/build +prune tests diff --git a/holidays/holiday_base.py b/holidays/holiday_base.py index 0ea3e2e24..6e2b4658d 100644 --- a/holidays/holiday_base.py +++ b/holidays/holiday_base.py @@ -579,12 +579,12 @@ def __repr__(self) -> str: parts.append(f"holidays.financial_holidays({self.market!r}") parts.append(")") elif hasattr(self, "country"): - if parts: - parts.append(" + ") parts.append(f"holidays.country_holidays({self.country!r}") if self.subdiv: parts.append(f", subdiv={self.subdiv!r}") parts.append(")") + else: + parts.append("holidays.HolidayBase()") return "".join(parts) diff --git a/pyproject.toml b/pyproject.toml index 75f5acb45..293f781b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,67 @@ +[project] +name = "holidays" +version = "0.34" +description = "Generate and work with holidays in Python" +license = { file = "LICENSE" } +readme = "README.rst" +requires-python = ">=3.8" + +authors = [{ email = "dr.prodigy.github@gmail.com", name = "Maurizio Montel" }] +dependencies = ["python-dateutil"] +classifiers = [ + "Classifier: Development Status :: 4 - Beta", + "Classifier: Intended Audience :: Developers", + "Classifier: License :: OSI Approved :: MIT License", + "Classifier: Operating System :: OS Independent", + "Classifier: Programming Language :: Python", + "Classifier: Programming Language :: Python :: 3", + "Classifier: Programming Language :: Python :: 3 :: Only", + "Classifier: Programming Language :: Python :: Implementation :: CPython", + "Classifier: Programming Language :: Python :: Implementation :: PyPy", + "Classifier: Topic :: Office/Business :: Scheduling", + "Classifier: Topic :: Software Development :: Libraries :: Python Modules", + "Classifier: Topic :: Software Development :: Localization", +] +keywords = ["holidays", "calendar", "l10n"] +maintainers = [{ email = "ark@cho.red", name = "Arkadii Yakovets" }] + +[project.urls] +Repository = "https://github.com/vacanza/python-holidays/" +Documentation = "https://python-holidays.readthedocs.io/en/latest/" +Changelog = "https://github.com/vacanza/python-holidays/releases" +Downloads = "https://pypi.org/project/holidays/" + [tool.black] line-length = 99 -target-version = ['py38', 'py39', 'py310', 'py311'] +target-version = ["py38", "py39", "py310", "py311"] [tool.coverage.run] branch = true -omit = ['scripts/*', 'setup.py', 'tests/*'] - -[tool.coverage.report] -exclude_lines = ['def __repr__', 'pragma: no cover'] +omit = ["scripts/*", "setup.py", "tests/*"] [tool.isort] -known_first_party = ['holidays', 'tests'] +known_first_party = ["holidays", "tests"] line_length = 99 multi_line_output = 3 no_inline_sort = true -profile = 'black' -skip = ['docs'] +profile = "black" +skip = ["docs"] + + +[tool.mypy] +strict = false + +[[tool.mypy.overrides]] +module = "holidays.countries.*" +disable_error_code = ["override"] + +[[tool.mypy.overrides]] +module = "holidays.groups.*" +disable_error_code = "attr-defined" + +[tool.rstcheck] +ignore_directives = ["automodule"] +ignore_languages = ["python"] + +[tool.setuptools.packages.find] +include = ["holidays*"] diff --git a/requirements/tests.txt b/requirements/tests.txt index a15cfbe9f..8f59b1d44 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,6 @@ # Test requirements. coverage +importlib-metadata pytest pytest-cov pytest-xdist diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 38daf391f..000000000 --- a/setup.cfg +++ /dev/null @@ -1,53 +0,0 @@ -[metadata] -name = holidays -version = attr: holidays.__version__ -description = Generate and work with holidays in Python -long_description = file: README.rst -long_description_content_type = text/x-rst -url = https://github.com/vacanza/python-holidays -author = Maurizio Montel (dr-prodigy) -author_email = dr.prodigy.github@gmail.com -maintainer = Arkadii Yakovets (arkid15r) -maintainer_email = ark@cho.red -license = MIT -license_files = LICENSE -platforms = any -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Topic :: Office/Business :: Scheduling - Topic :: Software Development :: Libraries :: Python Modules - Topic :: Software Development :: Localization - -[options] -packages = - holidays - holidays/countries - holidays/financial -install_requires = - python-dateutil -python_requires = >=3.8 -include_package_data = True - -[flake8] -extend-ignore = E203 - -[mypy] -strict = False - -[mypy-holidays.countries.*] -disable_error_code = override - -[mypy-holidays.groups.*] -disable_error_code = attr-defined - -[rstcheck] -ignore_directives = automodule -ignore_language = python diff --git a/tests/test_holiday_base.py b/tests/test_holiday_base.py index bd9efcef4..9551426b5 100644 --- a/tests/test_holiday_base.py +++ b/tests/test_holiday_base.py @@ -705,12 +705,15 @@ def test_partial(self): class TestRepr(unittest.TestCase): - def test_country(self): - hb = CountryStub1() - self.assertEqual(repr(hb), "holidays.country_holidays('CS1')") + def test_base(self): + self.assertEqual(repr(HolidayBase()), "holidays.HolidayBase()") - hb = CountryStub1(subdiv="Subdiv1") - self.assertEqual(repr(hb), "holidays.country_holidays('CS1', subdiv='Subdiv1')") + def test_country(self): + self.assertEqual(repr(CountryStub1()), "holidays.country_holidays('CS1')") + self.assertEqual( + repr(CountryStub1(subdiv="Subdiv1")), + "holidays.country_holidays('CS1', subdiv='Subdiv1')", + ) def test_market(self): self.assertEqual(repr(MarketStub1()), "holidays.financial_holidays('MS1')") diff --git a/tests/test_package.py b/tests/test_package.py new file mode 100644 index 000000000..bae69773d --- /dev/null +++ b/tests/test_package.py @@ -0,0 +1,43 @@ +# python-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: dr-prodigy (c) 2017-2023 +# ryanss (c) 2014-2017 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +from unittest import TestCase + +from importlib_metadata import metadata + +import holidays + + +class TestPackage(TestCase): + def test_metadata(self): + ph_metadata = metadata("holidays") + + for attr_name, attr_value in { + "name": "holidays", + "summary": "Generate and work with holidays in Python", + "version": holidays.__version__, + }.items(): + self.assertIn(attr_name, ph_metadata) + self.assertEqual(ph_metadata[attr_name], attr_value, attr_name) + + for attr_name in ( + "author-email", + "classifier", + "description", + "keywords", + "license", + "license-file", + "maintainer-email", + "project-url", + "requires-python", + ): + self.assertIn(attr_name, ph_metadata) + self.assertTrue(ph_metadata[attr_name], attr_name) diff --git a/tox.ini b/tox.ini index c5364d4f5..960f15599 100644 --- a/tox.ini +++ b/tox.ini @@ -34,6 +34,9 @@ commands = pre-commit autoupdate pre-commit run --all-files +[flake8] +extend-ignore = E203 + [pytest] filterwarnings = ignore:The --rsyncdir .* are deprecated:DeprecationWarning