diff --git a/.bumpversion.toml b/.bumpversion.toml new file mode 100644 index 0000000..99a6e72 --- /dev/null +++ b/.bumpversion.toml @@ -0,0 +1,13 @@ +[tool.bumpversion] +current_version = "0.0.1" +commit = true +tag = true +tag_name = "{new_version}" + +[[tool.bumpversion.files]] +filename = "docs/conf.py" +parse = 'version\s*=\s*"(?P\d+)\.(?P\d+)' + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +parse = 'version\s*=\s*"(?P\d+)\.(?P\d+)\.(?P\d+)' diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..9ee8f89 --- /dev/null +++ b/.flake8 @@ -0,0 +1,7 @@ +[flake8] +ignore = +per-file-ignores = + # D100-D104: Missing docstring + docs/conf.py:D100 + tests/__init__.py:D104 + tests/test_main.py:D100,D103 \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7eb333f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,27 @@ +name: publish +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/form2request + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # 1.9.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4daa67a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,72 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: tox + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - python-version: '3.8' + - python-version: '3.9' + - python-version: '3.10' + - python-version: '3.11' + - python-version: '3.12' + - python-version: '3.8' + toxenv: min + - python-version: '3.12' + toxenv: extra + - python-version: '3.8' + toxenv: min-extra + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox + - name: tox + run: | + tox -e ${{ matrix.toxenv || 'py' }} + - name: coverage + if: ${{ success() }} + run: bash <(curl -s https://codecov.io/bash) + + check: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ['3.12'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox + python -m pip install pre-commit + - name: tox + run: | + tox -e mypy + tox -e docs + tox -e twinecheck + tox -e linters diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b53725c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.coverage +/coverage.xml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..663563f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +repos: +- repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort +- repo: https://github.com/psf/black + rev: 24.4.2 + hooks: + - id: black +- repo: https://github.com/pycqa/flake8 + rev: 7.1.0 + hooks: + - id: flake8 + additional_dependencies: + - flake8-bugbear + - flake8-comprehensions + - flake8-debugger + - flake8-docstrings + - flake8-string-format +- repo: https://github.com/asottile/pyupgrade + rev: v3.16.0 + hooks: + - id: pyupgrade + args: [--py38-plus] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6817eb3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Zyte Group Ltd +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of Zyte nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..37f630a --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include tests * diff --git a/NEWS.rst b/NEWS.rst new file mode 100644 index 0000000..88e6c6e --- /dev/null +++ b/NEWS.rst @@ -0,0 +1,5 @@ +============= +Release notes +============= + +… diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..11b7e8e --- /dev/null +++ b/README.rst @@ -0,0 +1,29 @@ +============ +form2request +============ + +.. image:: https://img.shields.io/pypi/v/form2request.svg + :target: https://pypi.python.org/pypi/form2request + :alt: PyPI Version + +.. image:: https://img.shields.io/pypi/pyversions/form2request.svg + :target: https://pypi.python.org/pypi/form2request + :alt: Supported Python Versions + +.. image:: https://github.com/scrapy/form2request/workflows/test/badge.svg + :target: https://github.com/scrapy/form2request/actions + :alt: Build Status + +.. image:: https://codecov.io/github/scrapy/form2request/coverage.svg?branch=main + :target: https://codecov.io/gh/scrapy/form2request + :alt: Coverage report + +.. description starts + +``form2request`` is an AI-powered Python 3.8+ library to build HTTP requests +out of HTML forms. + +.. description ends + +* Documentation: https://form2request.readthedocs.io/en/latest/ +* License: BSD 3-clause diff --git a/dist/form2request-0.0.0.tar.gz b/dist/form2request-0.0.0.tar.gz new file mode 100644 index 0000000..f99bed9 Binary files /dev/null and b/dist/form2request-0.0.0.tar.gz differ diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 0000000..29c1176 --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,5 @@ +============= +API reference +============= + +… diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..acc9c71 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,19 @@ +project = "form2request" +copyright = "Zyte Group Ltd" +release = "0.0.0" + +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", +] + +html_theme = "sphinx_rtd_theme" + +autodoc_member_order = "groupwise" + +intersphinx_disabled_reftypes = [] +intersphinx_mapping = { + "lxml": ("https://lxml.de/apidoc/", None), + "parsel": ("https://parsel.readthedocs.io/en/stable", None), + "python": ("https://docs.python.org/3", None), +} diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..9ce1103 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,26 @@ +==================================== +form2request |release| documentation +==================================== + +.. include:: ../README.rst + :start-after: .. description starts + :end-before: .. description ends + +.. toctree:: + :caption: Getting started + :maxdepth: 1 + + setup + +.. toctree:: + :caption: Usage + :maxdepth: 1 + + usage + +.. toctree:: + :caption: Reference + :maxdepth: 1 + + api + news diff --git a/docs/news.rst b/docs/news.rst new file mode 100644 index 0000000..291074a --- /dev/null +++ b/docs/news.rst @@ -0,0 +1 @@ +.. include:: ../NEWS.rst diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..4e09d9c --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +Sphinx==7.3.7 +sphinx-rtd-theme==2.0.0 diff --git a/docs/setup.rst b/docs/setup.rst new file mode 100644 index 0000000..7c53e9c --- /dev/null +++ b/docs/setup.rst @@ -0,0 +1,9 @@ +===== +Setup +===== + +Install with pip: + +.. code-block:: bash + + pip install form2request diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..d9237b5 --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,5 @@ +===== +Usage +===== + +… diff --git a/form2request/__init__.py b/form2request/__init__.py new file mode 100644 index 0000000..4908450 --- /dev/null +++ b/form2request/__init__.py @@ -0,0 +1 @@ +"""Build HTTP requests out of HTML forms.""" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a566415 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "form2request" +version = "0.0.0" +description = "Build HTTP requests out of HTML forms" +authors = [{name = "Zyte Group Ltd", email = "info@zyte.com"}] +readme = "README.rst" +license = {file = "LICENSE"} +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.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +requires-python = ">=3.8" +dependencies = [ + "lxml >= 4.4.1", +] + +[project.urls] +Code = "https://github.com/zytedata/form2request" +Docs = "https://form2request.readthedocs.io/en/latest/" + +[tool.setuptools.package-data] +form2request = ["py.typed"] + +[tool.isort] +profile = "black" +multi_line_output = 3 + +[[tool.mypy.overrides]] +module = [ + "tests.*", +] +# Allow test functions to be untyped +disallow_untyped_defs = false diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..e6ef5c8 --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,2 @@ +def test_main(): + assert True diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..4de7873 --- /dev/null +++ b/tox.ini @@ -0,0 +1,51 @@ +[tox] +envlist = pre-commit,mypy,docs,twinecheck,min,py38,py39,py310,py311,py312 + +[testenv] +deps = + pytest + pytest-cov +commands = + pytest \ + --cov-report=term-missing:skip-covered \ + --cov-report=xml \ + --cov=form2request \ + --doctest-glob="*.rst" --doctest-modules \ + {posargs:docs form2request tests} + +[testenv:min] +basepython = python3.8 +deps = + {[testenv]deps} + lxml==4.4.1 + +[testenv:pre-commit] +deps = + pre-commit +commands = pre-commit run --all-files --show-diff-on-failure + +[testenv:mypy] +basepython = python3.12 +deps = + mypy==1.10.0 + +commands = mypy form2request tests + +[testenv:docs] +changedir = docs +deps = + -rdocs/requirements.txt +setenv = + READTHEDOCS_PROJECT=form2request + READTHEDOCS_VERSION=main +commands = + sphinx-build -W -n -b html . {envtmpdir}/html + +[testenv:twinecheck] +basepython = python3 +deps = + twine==5.1.0 + build==1.2.1 +commands = + python -m build --sdist + twine check dist/*