Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio committed Jun 18, 2024
0 parents commit b00ad76
Show file tree
Hide file tree
Showing 23 changed files with 374 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -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<major>\d+)\.(?P<minor>\d+)'

[[tool.bumpversion.files]]
filename = "pyproject.toml"
parse = 'version\s*=\s*"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)'
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
72 changes: 72 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.coverage
/coverage.xml
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include tests *
5 changes: 5 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=============
Release notes
=============

29 changes: 29 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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
Binary file added dist/form2request-0.0.0.tar.gz
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=============
API reference
=============

19 changes: 19 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -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),
}
26 changes: 26 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../NEWS.rst
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sphinx==7.3.7
sphinx-rtd-theme==2.0.0
9 changes: 9 additions & 0 deletions docs/setup.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=====
Setup
=====

Install with pip:

.. code-block:: bash
pip install form2request
5 changes: 5 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=====
Usage
=====

1 change: 1 addition & 0 deletions form2request/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Build HTTP requests out of HTML forms."""
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"}]
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
Empty file added tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_main():
assert True
51 changes: 51 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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/*

0 comments on commit b00ad76

Please sign in to comment.