From ebdb4ebf54ed3ab05969ed258818149c79e4a633 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 30 Apr 2020 14:42:26 +0100 Subject: [PATCH] Script cleanups --- httpcore/__init__.py | 2 ++ requirements.txt | 2 +- scripts/build | 2 -- scripts/check | 12 ++++++++---- scripts/clean | 21 +++++++++------------ scripts/install | 6 ++---- scripts/lint | 12 ++++++------ scripts/publish | 1 - scripts/test | 5 +++-- scripts/unasync | 5 +++-- setup.cfg | 21 --------------------- 11 files changed, 34 insertions(+), 55 deletions(-) delete mode 100644 setup.cfg diff --git a/httpcore/__init__.py b/httpcore/__init__.py index 74ce659d..115ec7e3 100644 --- a/httpcore/__init__.py +++ b/httpcore/__init__.py @@ -38,5 +38,7 @@ "ReadError", "WriteError", "CloseError", + "ProtocolError", + "ProxyError", ] __version__ = "0.8.0" diff --git a/requirements.txt b/requirements.txt index 8ae23a71..67c1d0f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,12 +13,12 @@ twine wheel # Tests & Linting +flake8 pytest pytest-asyncio pytest-trio pytest-cov black -autoflake mypy isort mitmproxy diff --git a/scripts/build b/scripts/build index 602eab0a..1c47d2cc 100755 --- a/scripts/build +++ b/scripts/build @@ -1,7 +1,5 @@ #!/bin/sh -e -PYTHONPATH=. - if [ -d 'venv' ] ; then PREFIX="venv/bin/" else diff --git a/scripts/check b/scripts/check index 7244efa1..7936be03 100755 --- a/scripts/check +++ b/scripts/check @@ -1,12 +1,16 @@ #!/bin/sh -e -export PREFIX="" +PACKAGE="httpcore" + if [ -d 'venv' ] ; then - export PREFIX="venv/bin/" + PREFIX="venv/bin/" +else + PREFIX="" fi -export SOURCE_FILES="httpcore tests" set -x -${PREFIX}mypy --ignore-missing-imports httpcore +${PREFIX}mypy --ignore-missing-imports ${PACKAGE} +${PREFIX}flake8 --max-line-length 88 ${PACKAGE} +${PREFIX}black --check --exclude '(httpcore/_sync|tests/sync_tests)/.*' --target-version=py37 ${PACKAGE} tests scripts/unasync --check diff --git a/scripts/clean b/scripts/clean index 3a639f5e..a9ca0e3b 100755 --- a/scripts/clean +++ b/scripts/clean @@ -1,14 +1,11 @@ #!/bin/sh -e -if [ -d 'dist' ] ; then - rm -r dist -fi -if [ -d 'site' ] ; then - rm -r site -fi -if [ -d 'htmlcov' ] ; then - rm -r htmlcov -fi -if [ -d 'httpcore.egg-info' ] ; then - rm -r httpcore.egg-info -fi +PACKAGE=httpcore + +rm -rf dist +rm -rf site +rm -rf htmlcov +rm -rf *.egg-info + +find ${PACKAGE} -type f -name "*.py[co]" -delete +find ${PACKAGE} -type f -name __pycache__ -delete diff --git a/scripts/install b/scripts/install index 65885a72..4e637a19 100755 --- a/scripts/install +++ b/scripts/install @@ -4,16 +4,14 @@ [ "$1" = "-p" ] && PYTHON=$2 || PYTHON="python3" REQUIREMENTS="requirements.txt" -VENV="venv" set -x if [ -z "$GITHUB_ACTIONS" ]; then - "$PYTHON" -m venv "$VENV" - PIP="$VENV/bin/pip" + "$PYTHON" -m venv venv + PIP="venv/bin/pip" else PIP="pip" fi "$PIP" install -r "$REQUIREMENTS" -"$PIP" install -e . diff --git a/scripts/lint b/scripts/lint index 0db7e266..6f847536 100755 --- a/scripts/lint +++ b/scripts/lint @@ -1,14 +1,14 @@ #!/bin/sh -e -export PREFIX="" +PACKAGE="httpcore" + if [ -d 'venv' ] ; then - export PREFIX="venv/bin/" + PREFIX="venv/bin/" +else + PREFIX="" fi -export SOURCE_FILES="httpcore tests" set -x -${PREFIX}autoflake --in-place --recursive $SOURCE_FILES -${PREFIX}isort --project=httpcore --recursive --apply $SOURCE_FILES -${PREFIX}black --exclude 'httpcore/_sync/.*' --exclude 'tests/sync_tests/.*' --target-version=py36 $SOURCE_FILES +${PREFIX}black --exclude '(httpcore/_sync|tests/sync_tests)/.*' --target-version=py37 ${PACKAGE} tests scripts/unasync diff --git a/scripts/publish b/scripts/publish index 1c4a3228..439780aa 100755 --- a/scripts/publish +++ b/scripts/publish @@ -1,7 +1,6 @@ #!/bin/sh -e VERSION_FILE="httpcore/__init__.py" -PYTHONPATH=. if [ -d 'venv' ] ; then PREFIX="venv/bin/" diff --git a/scripts/test b/scripts/test index 6a4a752f..1ffcdbd6 100755 --- a/scripts/test +++ b/scripts/test @@ -1,8 +1,9 @@ #!/bin/sh -e -export PREFIX="" if [ -d 'venv' ] ; then - export PREFIX="venv/bin/" + PREFIX="venv/bin/" +else + PREFIX="" fi set -x diff --git a/scripts/unasync b/scripts/unasync index 1e638205..aae29a6a 100755 --- a/scripts/unasync +++ b/scripts/unasync @@ -1,8 +1,9 @@ #!/bin/sh -e -export PREFIX="" if [ -d 'venv' ] ; then - export PREFIX="venv/bin/" + PREFIX="venv/bin/" +else + PREFIX="" fi ${PREFIX}python unasync.py ${@} diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 939e3cab..00000000 --- a/setup.cfg +++ /dev/null @@ -1,21 +0,0 @@ -[flake8] -ignore = W503, E203, B305 -max-line-length = 88 - -[mypy] -disallow_untyped_defs = True -ignore_missing_imports = True - -[tool:isort] -combine_as_imports = True -force_grid_wrap = 0 -include_trailing_comma = True -known_first_party = httpcore,tests -known_third_party = brotli,certifi,chardet,cryptography,h11,h2,hstspreload,pytest,rfc3986,setuptools,sniffio,trio,trustme,urllib3,uvicorn -line_length = 88 -multi_line_output = 3 - -[tool:pytest] -addopts = --cov=httpcore --cov=tests --cov-report=term-missing -rxXs -markers = - copied_from(source, changes=None): mark test as copied from somewhere else, along with a description of changes made to accodomate e.g. our test setup