diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 0000000..7c51009 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,3 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00a7b00 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5bd0054..8cf0795 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,14 +17,14 @@ jobs: max-parallel: 8 fail-fast: False matrix: - python-version: [ "3.7", "3.8", "3.9", "3.10" , "3.11", "3.12" ] + python-version: [ "3.7", "3.8", "3.9", "3.10" , "3.11", "3.12", "3.13"] include: - os: macos-latest - python-version: "3.12" + python-version: "3.13" - os: windows-latest - python-version: "3.12" + python-version: "3.13" - os: macos-14 # Apple silicon runner - python-version: '3.12' + python-version: '3.13' name: tests on ubuntu with ${{ matrix.python-version }} steps: - uses: actions/checkout@v4 @@ -35,12 +35,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install . - pip install cython + pip install .[dev] cython coveralls coverage - name: Test with pytest run: | - . ci/install_tester.sh . ci/run_tests.sh - name: Build docs run: | diff --git a/.gitignore b/.gitignore index 813eee0..1bf041f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ dist MANIFEST /.hypothesis/ *.coverage +/docs/api/_build/ +/.idea/ +/src/yamlloader/_version.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a1ee45..f0f6c9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -16,13 +16,6 @@ repos: - id: fix-byte-order-marker - id: check-ast - - - repo: https://github.com/myint/docformatter - rev: v1.7.5 - hooks: - - id: docformatter - args: [ -r, --in-place, --wrap-descriptions, '120', --wrap-summaries, '120', -- ] - - repo: https://github.com/mattlqx/pre-commit-sign rev: v1.2.0 hooks: @@ -36,39 +29,45 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + rev: v3.19.0 hooks: - id: pyupgrade - args: [ --py36-plus ] + args: [ --py37-plus ] - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.5.0 + rev: v2.7.0 hooks: - id: setup-cfg-fmt # Notebook formatting - repo: https://github.com/nbQA-dev/nbQA - rev: 1.8.5 + rev: 1.8.7 hooks: - id: nbqa-isort additional_dependencies: [ isort ] - id: nbqa-pyupgrade additional_dependencies: [ pyupgrade ] - args: [ --py36-plus ] + args: [ --py37-plus ] - repo: https://github.com/mgedmin/check-manifest - rev: '0.49' + rev: '0.50' hooks: - id: check-manifest stages: [ manual ] + # auto walrus + - repo: https://github.com/MarcoGorelli/auto-walrus + rev: 0.3.4 + hooks: + - id: auto-walrus + - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.7" + rev: "v0.7.1" hooks: - id: ruff types_or: [ python, pyi, jupyter ] - args: [ --fix, --unsafe-fixes, --show-fixes , --line-length=120] + args: [ --fix, --unsafe-fixes, --show-fixes , --line-length=120 ] # Run the formatter. - id: ruff-format types_or: [ python, pyi, jupyter ] diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 8da04a0..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include README.rst -include LICENSE -include requirements.txt diff --git a/ci/install_tester.sh b/ci/install_tester.sh deleted file mode 100644 index 7774215..0000000 --- a/ci/install_tester.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# install test environment -pip install coverage > tmp.txt && echo "alive"; -#conda install -y coverage > tmp.txt && echo "alive"; -pip install coveralls > tmp.txt && echo "alive"; -pip install hypothesis pytest diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 827a9e3..875f4db 100644 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash -coverage run --source=. --branch -m unittest discover && coverage report yamlloader/*.py +coverage run --source=. --branch -m unittest discover && coverage report src/yamlloader/*.py coverage report diff --git a/docs/api/static/img/phynix_logo_medium.png b/docs/api/_static/img/phynix_logo_medium.png similarity index 100% rename from docs/api/static/img/phynix_logo_medium.png rename to docs/api/_static/img/phynix_logo_medium.png diff --git a/docs/api/conf.py b/docs/api/conf.py index 2d9be84..2b7d0e0 100644 --- a/docs/api/conf.py +++ b/docs/api/conf.py @@ -31,8 +31,6 @@ # Manually added things -import sphinx_rtd_theme - import yamlloader here = Path(__file__).resolve().parent @@ -43,7 +41,7 @@ html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] +# html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -60,7 +58,7 @@ "sphinx.ext.githubpages", ] -html_logo = here / "static/img/phynix_logo_medium.png" +html_logo = str(here / "_static/img/phynix_logo_medium.png") # Napoleon settings (convert numpy/google docstrings to proper ReST napoleon_google_docstring = False @@ -131,8 +129,8 @@ # # html_theme_options = {} -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, +# Add any paths that contain custom _static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin _static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] @@ -228,6 +226,3 @@ # A list of files that should not be packed into the epub file. epub_exclude_files = ["search.html"] - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {"https://docs.python.org/": None} diff --git a/docs/api/yamlloader.ordereddict.dumpers.rst b/docs/api/yamlloader.ordereddict.dumpers.rst index 9ef96ec..59fd2f9 100644 --- a/docs/api/yamlloader.ordereddict.dumpers.rst +++ b/docs/api/yamlloader.ordereddict.dumpers.rst @@ -2,6 +2,6 @@ dumpers ======= .. automodule:: yamlloader.ordereddict.dumpers - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/yamlloader.ordereddict.loaders.rst b/docs/api/yamlloader.ordereddict.loaders.rst index 52019b8..1139a79 100644 --- a/docs/api/yamlloader.ordereddict.loaders.rst +++ b/docs/api/yamlloader.ordereddict.loaders.rst @@ -2,6 +2,6 @@ loaders ======= .. automodule:: yamlloader.ordereddict.loaders - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/yamlloader.ordereddict.rst b/docs/api/yamlloader.ordereddict.rst index 0f08bc5..d779ccc 100644 --- a/docs/api/yamlloader.ordereddict.rst +++ b/docs/api/yamlloader.ordereddict.rst @@ -2,14 +2,15 @@ ordereddict =========== .. automodule:: yamlloader.ordereddict - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: Submodules ---------- .. toctree:: + :maxdepth: 4 yamlloader.ordereddict.dumpers yamlloader.ordereddict.loaders diff --git a/docs/api/yamlloader.rst b/docs/api/yamlloader.rst index 29bb6b2..cca8345 100644 --- a/docs/api/yamlloader.rst +++ b/docs/api/yamlloader.rst @@ -2,13 +2,23 @@ yamlloader package ================== .. automodule:: yamlloader - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: Subpackages ----------- .. toctree:: + :maxdepth: 4 - yamlloader.ordereddict + yamlloader.ordereddict + +Submodules +---------- + +.. toctree:: + :maxdepth: 4 + + yamlloader.settings + yamlloader.version diff --git a/docs/api/yamlloader.settings.rst b/docs/api/yamlloader.settings.rst new file mode 100644 index 0000000..0f632d5 --- /dev/null +++ b/docs/api/yamlloader.settings.rst @@ -0,0 +1,7 @@ +settings +======== + +.. automodule:: yamlloader.settings + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/yamlloader.version.rst b/docs/api/yamlloader.version.rst new file mode 100644 index 0000000..1afa935 --- /dev/null +++ b/docs/api/yamlloader.version.rst @@ -0,0 +1,7 @@ +version +======= + +.. automodule:: yamlloader.version + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/make_docs.sh b/docs/make_docs.sh index 718bcf5..e4f6d14 100755 --- a/docs/make_docs.sh +++ b/docs/make_docs.sh @@ -6,7 +6,7 @@ MAKE_DOCS_PATH="$( cd "$(dirname "$0")" ; pwd -P )" popd > /dev/null # generate the ReST files -sphinx-apidoc -o ${MAKE_DOCS_PATH}/api ${MAKE_DOCS_PATH}/../yamlloader -fMeT && \ +sphinx-apidoc -o ${MAKE_DOCS_PATH}/api ${MAKE_DOCS_PATH}/../src/yamlloader -fMeT && \ python ${MAKE_DOCS_PATH}/api/tools/change_headline.py ${MAKE_DOCS_PATH}/api/yamlloader.* && \ make -C ${MAKE_DOCS_PATH}/api clean && make -C ${MAKE_DOCS_PATH}/api html -j4 && \ echo "Documentation successfully built!" || echo "FAILED to build Documentation" diff --git a/pyproject.toml b/pyproject.toml index da34e1e..a1a2035 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,65 @@ [build-system] requires = [ - "setuptools>=42", -# "setuptools_scm[toml]>=3.4", -# "setuptools_scm_git_archive", - "wheel" + "hatchling", + "hatch-vcs", ] -build-backend = "setuptools.build_meta" +build-backend = "hatchling.build" + +[project] +name = "yamlloader" +description = "Ordered YAML loader and dumper for PyYAML." +readme = "README.rst" +authors = [ + { name = "Jonas Eschle", email = "jonas.eschle@gmail.com" }, + { name = "Johannes Lade", email = "johannes.lade@phynix.science" }, +] +maintainers = [ + { name = "Jonas Eschle", email = "jonas.eschle@gmail.com" }, +] +keywords = [ + "yaml", + "loader", + "dumper", + "ordered", + "dict", + "PyYAML", +] + +dynamic = ["version"] +dependencies = [ + "pyyaml", +] + + + +license.file = "LICENSE" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Software Development :: Libraries", + "Topic :: Utilities", +] + + +[project.optional-dependencies] +test = ["pytest", "hypothesis"] +doc = ["sphinx", "sphinx-rtd-theme", "sphinx-autodoc-typehints", "sphinxcontrib-apidoc"] +dev = ['yamlloader[test,doc]'] +[project.urls] +Homepage = "https://github.com/Phynix/yamlloader" +Documentation = "https://yamlloader.readthedocs.io/" + +[tool.hatch] +version.source = "vcs" +build.hooks.vcs.version-file = "src/yamlloader/_version.py" [tool.ruff] #src = ["src"] @@ -19,41 +72,41 @@ exclude = [ ] [tool.ruff.lint] extend-select = [ - "B", # flake8-bugbear - "I", # isort - "ARG", # flake8-unused-arguments - "C4", # flake8-comprehensions - "EM", # flake8-errmsg - "ICN", # flake8-import-conventions - "G", # flake8-logging-format - "PGH", # pygrep-hooks - "PIE", # flake8-pie - "PL", # pylint - "PT", # flake8-pytest-style - "PTH", # flake8-use-pathlib - "RET", # flake8-return - "RUF", # Ruff-specific - "SIM", # flake8-simplify - "T20", # flake8-print - "UP", # pyupgrade - "YTT", # flake8-2020 - "EXE", # flake8-executable - "NPY", # NumPy specific rules - "PD", # pandas-vet + "B", # flake8-bugbear + "I", # isort + "ARG", # flake8-unused-arguments + "C4", # flake8-comprehensions + "EM", # flake8-errmsg + "ICN", # flake8-import-conventions + "G", # flake8-logging-format + "PGH", # pygrep-hooks + "PIE", # flake8-pie + "PL", # pylint + "PT", # flake8-pytest-style + "PTH", # flake8-use-pathlib + "RET", # flake8-return + "RUF", # Ruff-specific + "SIM", # flake8-simplify + "T20", # flake8-print + "UP", # pyupgrade + "YTT", # flake8-2020 + "EXE", # flake8-executable + "NPY", # NumPy specific rules + "PD", # pandas-vet ] ignore = [ - "UP007", # type annotation upgrade, breaks pydantic for Python 3.9 (remove once above) - "PLR09", # Too many <...> - "PLR2004", # Magic value used in comparison - "ISC001", # Conflicts with formatter - "RET505", # This is sometimes wanted, protets against accidental intendation - "PD901", # "avoid using `df[...].values`" -> no, this is a very good name if there is only one df - "PD011", # "replace `df[...].values` with `df[...].to_numpy()`" -> not yet, it's not deprecated. + "UP007", # type annotation upgrade, breaks pydantic for Python 3.9 (remove once above) + "PLR09", # Too many <...> + "PLR2004", # Magic value used in comparison + "ISC001", # Conflicts with formatter + "RET505", # This is sometimes wanted, protets against accidental intendation + "PD901", # "avoid using `df[...].values`" -> no, this is a very good name if there is only one df + "PD011", # "replace `df[...].values` with `df[...].to_numpy()`" -> not yet, it's not deprecated. # Prefer to have a single way to access the data if we don't care about whether it's a numpy array or not. - "PLW0603", # updating global variables with a function is bad, but we use it for - "PLW2901", # "for loop overwritten by assignment" -> we use this to update the loop variable - "PD013", # "melt over stack": df function, but triggers on tensors - "NPY002", # "Use rnd generator in numpy" -> we use np.random for some legacy stuff but do use the new one where we can + "PLW0603", # updating global variables with a function is bad, but we use it for + "PLW2901", # "for loop overwritten by assignment" -> we use this to update the loop variable + "PD013", # "melt over stack": df function, but triggers on tensors + "NPY002", # "Use rnd generator in numpy" -> we use np.random for some legacy stuff but do use the new one where we can ] isort.required-imports = ["from __future__ import annotations"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c3726e8..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyyaml diff --git a/setup.py b/setup.py deleted file mode 100644 index 4ba6042..0000000 --- a/setup.py +++ /dev/null @@ -1,56 +0,0 @@ -from __future__ import annotations - -from pathlib import Path - -from setuptools import setup - -here = Path(__file__).resolve().parent - -with (here / "requirements.txt").open() as f: - requirements = f.read().split("\n") - - -def long_description(): - """Load README.rst.""" - with Path("README.rst").open(encoding="utf-8") as f: - return f.read() - - -dev_requiremnets = ["pytest", "hypothesis"] -setup( - name="yamlloader", - version="1.4.1", - author='Jonas Eschle "Mayou36", Johannes Lade "SebastianJL"', - author_email="jonas.eschle@phynix.science, johannes.lade@phynix.science", - maintainer='Jonas Eschle "Mayou36"', - maintainer_email="jonas.eschle@phynix.science", - url="https://github.com/Phynix/yamlloader", - download_url="https://github.com/Phynix/yamlloader", - license="MIT License", - description="Ordered YAML loader and dumper for PyYAML.", - long_description=long_description(), - keywords=["YAML", "loader", "dumper", "ordered", "OrderedDict", "pyyaml"], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Intended Audience :: System Administrators", - "Intended Audience :: Science/Research", - "Natural Language :: English", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development :: Libraries", - "Topic :: Utilities", - ], - packages=["yamlloader", "yamlloader.ordereddict"], - python_requires=">=3.7", - install_requires=requirements, - tests_require=dev_requiremnets, - extras_require={"dev": dev_requiremnets}, - zip_safe=False, -) diff --git a/yamlloader/__init__.py b/src/yamlloader/__init__.py similarity index 100% rename from yamlloader/__init__.py rename to src/yamlloader/__init__.py diff --git a/yamlloader/ordereddict/__init__.py b/src/yamlloader/ordereddict/__init__.py similarity index 100% rename from yamlloader/ordereddict/__init__.py rename to src/yamlloader/ordereddict/__init__.py diff --git a/yamlloader/ordereddict/dumpers.py b/src/yamlloader/ordereddict/dumpers.py similarity index 100% rename from yamlloader/ordereddict/dumpers.py rename to src/yamlloader/ordereddict/dumpers.py diff --git a/yamlloader/ordereddict/loaders.py b/src/yamlloader/ordereddict/loaders.py similarity index 100% rename from yamlloader/ordereddict/loaders.py rename to src/yamlloader/ordereddict/loaders.py diff --git a/yamlloader/settings.py b/src/yamlloader/settings.py similarity index 100% rename from yamlloader/settings.py rename to src/yamlloader/settings.py