From 6e1f343eea71874347a5632f0f34ac7e735873c4 Mon Sep 17 00:00:00 2001 From: Alexandre Decan Date: Thu, 17 Oct 2024 15:04:06 +0200 Subject: [PATCH] Migrate to ruff & full pyproject --- .github/workflows/test.yaml | 6 +++-- .gitignore | 8 +------ CHANGELOG.md | 8 +++++++ README.md | 2 +- portion/dict.py | 5 ++-- pyproject.toml | 43 ++++++++++++++++++++++++++++----- setup.py | 47 ++----------------------------------- 7 files changed, 56 insertions(+), 63 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e086dd7..3e23d55 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - name: Set up Python @@ -29,7 +29,9 @@ jobs: - name: Install test dependencies run: pip install .[test] - name: Check code style - run: black --check portion + run: | + ruff check --output-format=github + ruff format --check - name: Execute tests run: coverage run --source portion -m pytest - name: Upload coverage to Coveralls diff --git a/.gitignore b/.gitignore index d0e869e..b45046e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,4 @@ *__pycache__* +.* *.pyc *.egg-info* -.coverage -.mypy_cache -.idea -.vscode -.pytest_cache -.hypothesis -perfs.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0709309..febc6e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 2.6.1 (not yet released) + +### Changed + - Switch from `black` to `ruff` for code style. + - Fully migrate to a `pyproject.toml`-based project. + - Drop official support for Python 3.8. + + ## 2.6.0 (2024-10-17) ### Added diff --git a/README.md b/README.md index 666eb7d..92f80da 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ You can use `pip` to install it, as usual: `pip install portion`. This will inst Pre-releases are available from the *master* branch on [GitHub](https://github.com/AlexandreDecan/portion) and can be installed with `pip install git+https://github.com/AlexandreDecan/portion`. Note that `portion` is also available on [conda-forge](https://anaconda.org/conda-forge/portion). -You can install `portion` and its development environment using `pip install -e .[test]` at the root of this repository. This automatically installs [pytest](https://docs.pytest.org/en/latest/) (for the test suites) and [black](https://black.readthedocs.io/en/stable/) (for code formatting). +You can install `portion` and its development environment using `pip install -e .[test]` at the root of this repository. This automatically installs [pytest](https://docs.pytest.org/en/latest/) (for the test suites) and [ruff](https://docs.astral.sh/ruff/) (for code style). ## Documentation & usage diff --git a/portion/dict.py b/portion/dict.py index 6135026..bf2184c 100644 --- a/portion/dict.py +++ b/portion/dict.py @@ -244,10 +244,11 @@ def combine(self, other, how, *, missing=..., pass_interval=False): new_items = [] if not pass_interval: - _how = lambda x, y, i: how(x, y) + + def _how(x, y, i): + return how(x, y) else: _how = how - dom1, dom2 = self.domain(), other.domain() if missing is Ellipsis: diff --git a/pyproject.toml b/pyproject.toml index 143e064..1b0b871 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,40 @@ [build-system] -requires = [ - "setuptools >= 40.9.0", - "wheel", -] +requires = ["setuptools >= 61.0"] build-backend = "setuptools.build_meta" -[tool.black] -force-exclude = 'tests/' +[project] +name = "portion" +version = "2.6.1" +license = { text = "LGPLv3" } +authors = [{ name = "Alexandre Decan", email = "alexandre.decan@lexpage.net" }] +description = "Python data structure and operations for intervals" +readme = { file = "README.md", content-type = "text/markdown" } +urls = { Homepage = "https://github.com/AlexandreDecan/portion" } +keywords = ["interval", "range", "span"] +requires-python = "~= 3.9" +dependencies = ["sortedcontainers ~= 2.2"] +classifiers = [ + "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Information Technology", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Mathematics", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] + +[project.optional-dependencies] +test = ["pytest ~= 7.0", "coverage ~= 6.0", "ruff >= 0.6.9"] + +[tool.ruff] +extend-exclude = ["tests/"] + +[tool.setuptools] +packages = ["portion"] diff --git a/setup.py b/setup.py index c2396af..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,46 +1,3 @@ -from os import path -from setuptools import setup, find_packages -from codecs import open +from setuptools import setup -with open( - path.join(path.abspath(path.dirname(__file__)), "README.md"), encoding="utf-8" -) as f: - long_description = f.read() - -setup( - name="portion", - version="2.6.0", - license="LGPLv3", - author="Alexandre Decan", - url="https://github.com/AlexandreDecan/portion", - description="Python data structure and operations for intervals", - long_description=long_description, - long_description_content_type="text/markdown", - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Information Technology", - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering :: Mathematics", - "Programming Language :: Python :: 3 :: Only", - "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", - "Programming Language :: Python :: 3.13", - ], - keywords="interval operation range math", - packages=find_packages(include=["portion"]), - python_requires="~= 3.8", - install_requires=[ - "sortedcontainers ~= 2.2", - ], - extras_require={ - "test": ["pytest ~= 7.0", "coverage ~= 6.0", "black >= 21.8b"], - }, - zip_safe=True, -) +setup()