Repository: zytedata/zyte-common-items (language: python)

Issue:
Migration from setup.py to pyproject.toml
Integrating the various tests, linters, formatters and docs generators to modern python using pyproject.toml 


Discussion / hints:

Fix patch:
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
deleted file mode 100644
index 9dda257..0000000
--- a/.bumpversion.cfg
+++ /dev/null
@@ -1,7 +0,0 @@
-[bumpversion]
-current_version = 0.26.0
-commit = True
-tag = True
-tag_name = {new_version}
-
-[bumpversion:file:zyte_common_items/VERSION]
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 820c29d..86dc27b 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -8,25 +8,25 @@ on:
     tags:
       - "[0-9]+.[0-9]+.[0-9]+"
 
+concurrency:
+  group: ${{github.workflow}}-${{ github.ref }}
+  cancel-in-progress: true
+
 jobs:
   deploy:
     runs-on: ubuntu-latest
-
     steps:
-    - uses: actions/checkout@v4
-    - name: Set up Python
-      uses: actions/setup-python@v5
-      with:
-        python-version: '3.13'
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install setuptools wheel twine
-    - name: Build and publish
-      if: startsWith(github.ref, 'refs/tags')
-      env:
-        TWINE_USERNAME: __token__
-        TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
-      run: |
-        python setup.py sdist bdist_wheel
-        twine upload dist/*
+      - uses: actions/checkout@v4
+      - uses: actions/setup-python@v5
+        with:
+          python-version: '3.13'
+      
+      - name: Build package
+        run: |
+          pip install --upgrade build
+          python -m build
+      
+      - name: Publish to PyPI
+        uses: pypa/gh-action-pypi-publish@v1.10.3
+        with:
+          password: ${{ secrets.PYPI_TOKEN }}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index f80be43..cff7287 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ docs/_build/
 docs/_autosummary/
 coverage.xml
 .idea/
+venv/
\ No newline at end of file
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 85b4eba..0000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,1 +0,0 @@
-include zyte_common_items/VERSION
diff --git a/pyproject.toml b/pyproject.toml
index eac6704..1211246 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,55 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "zyte-common-items"
+dynamic = ["version"]
+description = "Item definitions for Zyte API schema"
+readme = { file = "README.rst", content-type = "text/x-rst" }
+requires-python = ">=3.9"
+authors = [{ name = "Zyte Group Ltd", email = "info@zyte.com" }]
+classifiers = [
+    "Development Status :: 3 - Alpha",
+    "Intended Audience :: Developers",
+    "License :: OSI Approved :: BSD License",
+    "Natural Language :: English",
+    "Operating System :: OS Independent",
+    "Programming Language :: Python :: 3",
+    "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",
+    "Programming Language :: Python :: Implementation :: CPython",
+]
+dependencies = [
+    "attrs>=22.2.0",
+    "clear-html>=0.4.0",
+    "itemadapter>=0.8.0",
+    "Jinja2>=2.7",
+    "price-parser>=0.3.4",
+    "web-poet>=0.14.0",
+    "zyte-parsers>=0.5.0",
+]
+
+[project.urls]
+source = "https://github.com/zytedata/zyte-common-items"
+issues = "https://github.com/zytedata/zyte-common-items/issues"
+documentation = "https://zyte-common-items.readthedocs.io/en/stable/"
+changelog = "https://github.com/zytedata/zyte-common-items/blob/main/CHANGELOG.rst"
+
+[tool.setuptools.dynamic]
+version = { file = "zyte_common_items/VERSION" }
+
+[tool.setup_tools.package-data]
+zyte_common_items = ["py.typed","VERSION"]
+
+[tool.setuptools.packages.find]
+include = ["zyte_common_items"]
+
 [tool.black]
-exclude = 'test_mypy\.py'  # https://github.com/davidfritzsche/pytest-mypy-testing/issues/29
+exclude = 'test_mypy\.py' # https://github.com/davidfritzsche/pytest-mypy-testing/issues/29
 
 [tool.isort]
 profile = "black"
@@ -8,13 +58,19 @@ multi_line_output = 3
 [tool.mypy]
 check_untyped_defs = true
 ignore_missing_imports = true
-no_warn_no_return = true
-exclude = [
-    'test_mypy\.py$',
-    'test_conversion\.py$',
-]
+warn_no_return = false
+exclude = ['test_mypy\.py$', 'test_conversion\.py$']
 
 [tool.pytest.ini_options]
 filterwarnings = [
     'ignore:The zyte_common_items.ae module .*:DeprecationWarning',
-]
\ No newline at end of file
+]
+
+[tool.bumpversion]
+current_version = "0.26.0"
+commit = true
+tag = true
+tag_name = "{new_version}"
+
+[[tool.bumpversion.files]]
+filename = "zyte_common_items/VERSION"
\ No newline at end of file
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 86945c5..14aae9b 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,4 +1,4 @@
-bump2version
+bump-my-version
 pre-commit
 pytest
 mypy
diff --git a/setup.py b/setup.py
deleted file mode 100644
index ee7af26..0000000
--- a/setup.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from os.path import dirname, join
-
-from setuptools import find_packages, setup
-
-with open(join(dirname(__file__), "zyte_common_items/VERSION"), "rb") as f:
-    version = f.read().decode("ascii").strip()
-
-setup(
-    name="zyte-common-items",
-    version=version,
-    description="Item definitions for Zyte API schema",
-    long_description=open("README.rst").read(),
-    long_description_content_type="text/x-rst",
-    author="Zyte Group Ltd",
-    author_email="info@zyte.com",
-    url="https://github.com/zytedata/zyte-common-items",
-    packages=find_packages(
-        exclude=[
-            "tests",
-        ]
-    ),
-    package_data={
-        "zyte_common_items": ["py.typed", "VERSION"],
-    },
-    # needs to be in sync with the tox.ini min env
-    install_requires=[
-        "attrs>=22.2.0",
-        "clear-html>=0.4.0",
-        "itemadapter>=0.8.0",
-        "Jinja2>=2.7",
-        "price-parser>=0.3.4",
-        "web-poet>=0.14.0",
-        "zyte-parsers>=0.5.0",
-    ],
-    classifiers=[
-        "Development Status :: 3 - Alpha",
-        "Intended Audience :: Developers",
-        "License :: OSI Approved :: BSD License",
-        "Natural Language :: English",
-        "Operating System :: OS Independent",
-        "Programming Language :: Python :: 3",
-        "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",
-        "Programming Language :: Python :: Implementation :: CPython",
-    ],
-    python_requires=">=3.9",
-)
diff --git a/tox.ini b/tox.ini
index 1350029..cc78beb 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,4 +1,5 @@
 [tox]
+min_version = 4.20
 envlist = min,min-extra,py39,py310,py311,py312,py313,extra,mypy,docs,twinecheck
 
 [base]
@@ -15,7 +16,7 @@ deps =
 deps =
     {[base]deps}
 commands =
-    py.test \
+    pytest \
         --cov-report=term-missing:skip-covered \
         --cov-report=html \
         --cov-report= \


Test patch:
diff --git a/tests/test_request_templates.py b/tests/test_request_templates.py
index 17c818a..c7e3e3e 100644
--- a/tests/test_request_templates.py
+++ b/tests/test_request_templates.py
@@ -280,11 +280,14 @@ async def test_request_no_parameters():
 async def test_request_template_keyword_call_keyword():
     page = KeywordSearchRequestTemplatePage(RequestUrl("https://example.com"))
     search_request_template = await page.to_item()
-    with pytest.warns(
-        DeprecationWarning, match=r"Replace the 'keyword' variable with 'query'"
-    ), pytest.warns(
-        DeprecationWarning,
-        match=r"The 'keyword' parameter of request\(\) is deprecated",
+    with (
+        pytest.warns(
+            DeprecationWarning, match=r"Replace the 'keyword' variable with 'query'"
+        ),
+        pytest.warns(
+            DeprecationWarning,
+            match=r"The 'keyword' parameter of request\(\) is deprecated",
+        ),
     ):
         search_request = search_request_template.request(keyword="foo")
     assert search_request.url == "https://example.com/?search=foo"